User:Liflon/Help:維基代碼

维基百科,自由的百科全书

維基代碼MediaWiki軟件用來決定頁面樣式的語法和關鍵詞。Help:備忘單有維基代碼的簡短入門;想知道如何檢閱頁面的代碼以及編輯頁面的話,可以去看Help:編輯頁面

頁面排版

章節

章節標題

=”到“======”這幾組等號代碼是用來標示相應章節的標題的。

  • 單獨的“=”會以頁面標題的樣式顯示,不應該用在頁面內。
  • 各標題以CSS指定樣式,並且會添加“[編輯]”連結。
  • 頁面內有四個章節標題或以上的話,便會自動生成頁面目錄。
  • 不要在標題代碼後(同一行內)輸入其他代碼,因為這樣會使標題損壞,或者令標題不會出現在編輯摘要中。
代码 效果
== 章節 ==
章節
=== 下層章節 ===
下層章節
==== 下下層章節 ====
下下層章節

如此類推。

維基式標題會轉換成HTML標題元素<h1><h6>,並預設用以下樣式顯示:

Help:HTML in wikitext

相關模板:{{fake heading}},可以用在說明文檔中,會生成不顯示在頁面目錄裡的假標題。

水平線

水平線代表段落之間主題上的分隔,不應該用在條目內容裡。

代码 效果
----


HTML標籤:<hr />

頁面目錄

頁面含有四個章節標題或以上時,頁面目錄便會自動出現在序言章節和第一個標題之間。這個目錄可以用魔術字或模板控制:

  • __FORCETOC__”會強制將目錄顯示在正常會出現的位置,不管頁面一共含有多少個章節標題。
  • __TOC__”會強制將目錄顯示在該魔術字出現的地方,而不是目錄正常會出現的位置。
  • __NOTOC__”會徹底隱藏目錄。
  • {{TOC limit}}可以控制目錄所顯示的下層章節深度,在目錄太冗長時十分有用。
  • Category:目錄模板收納了帶有特殊功能的不同目錄模板。

換行

換行的作用是在不同行之間添加空白,例如分隔不同的段落。

  • 要添加在內容裡看得到的換行,可以按兩下 ↵ Enter
  • 按一下 ↵ Enter 的話會在代碼中添加換行,但在生成內容時只會顯示為空格,除了使用列表標記時。
  • 粗體和斜體等標記會在換行時終止。
代码 效果
單次換行對頁面排版
並沒有任何影響,除了會添加空格。

空行則會開啟
新的段落,也會結束列表或
終止某段文字的縮進效果。

單次換行對頁面排版 並沒有任何影響,除了會添加空格。

空行則會開啟 新的段落,也會結束列表或 終止某段文字的縮進效果。

HTML標籤:<br><br />

相關模板:

  • {{crlf2}}可以添加真正的回車及換行。
  • {{-}}可以添加空行,用來分隔浮動的HTML元素和隨後出現的其他元素。
  • {{plainlist}}可以建立無序列表。

縮進文字

縮進效果最常用於討論頁。

代码 效果
在討論頁裡可以這樣使用縮進效果:
:每行開頭的冒號
::都會使該行文字縮進三個字母的空間。
:::(縮進效果會一直維持
直到遇上換行。)
:::如果要換行,就要再次縮進。
::::每次回覆時再添加一個冒號。
:::::如此……
::::::類推……

在討論頁裡可以這樣使用縮進效果:

每行開頭的冒號
都會使該行文字縮進三個字母的空間。
(縮進效果會一直維持

直到遇上換行。)

如果要換行,就要再次縮進。
每次回覆時再添加一個冒號。
如此……
類推……

相關模板:{{outdent}}、{{outdent2}}

塊狀引用

可以在需要分隔開一段文字時使用,尤其是添加一整段的引述文字時。

代码 效果
<blockquote>
這個“'''blockquote'''”標籤會縮進頁面兩邊的空間,而不是像用冒號般只縮進左邊。
</blockquote>

這個“blockquote”標籤會縮進頁面兩邊的空間,而不是像用冒號般只縮進左邊。

文字居中對齊

代码 效果
<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">居中對齊的文字</div>
居中對齊的文字

{{center}}模板用的是同樣的代碼。要將表格居中定位的話,參見Help:表格#表格居中

不要用<center>...</center>;這個標籤已經被廢除了。

文字靠右對齊

代码 效果
<div style="text-align:right; direction:ltr; margin-left:1em;">靠右對齊的文字</div>
靠右對齊的文字

列表

除非有特殊原因,否則不要在列表的各項之間留有空行,因為這樣會使MediaWiki軟件視每一項為另一個列表的開始。

無序列表

代码 效果
* 第1項
* 第2項
* 第3項
* 第4項
** 第4項甲
*** 第4項甲(一)
**** 第4項甲(一)i.
**** 第4項甲(一)ii.
** 第4項乙
* 第5項

  • 第1項
  • 第2項
  • 第3項
  • 第4項
    • 第4項甲
      • 第4項甲(一)
        • 第4項甲(一)i.
        • 第4項甲(一)ii.
    • 第4項乙
  • 第5項

有序列表

代码 效果
# 第1項
# 第2項
# 第3項
# 第4項
## 子項1
### 子項
#### 子項
## 子項2
# 第5項

  1. 第1項
  2. 第2項
  3. 第3項
  4. 第4項
    1. 子項1
      1. 子項
        1. 子項
    2. 子項2
  5. 第5項

定義列表

要列出詞彙及其定義的話,在新的一行輸入分號(;)和該詞彙,接下來輸入冒號(:)和這個詞彙的定義。

定義列表由組名與其對應的賦值構成。組名(詞彙)會顯示為粗體文字,而賦值(定義)則會縮進排列。每一組內必須包含起碼一項定義。只有一項定義或者這個定義是一系列中的第一個時,“:”可以與“;”放在同一行裡,出現在其後面,但其餘定義必須另開新行放置。

注意:在沒有同時用冒號(:)添加定義的情況下,不要濫用分號(;)來將一行文字變成粗體。這種用法會生成不合規格的HTML5代碼。

代码 效果
; 詞彙 : 定義1

詞彙
定義1
; 詞彙
: 定義1
: 定義2
: 定義3
: 定義4

詞彙
定義1
定義2
定義3
定義4

HTML標籤:<dl><dt>...</dt><dd>...</dd></dl>

相關模板:{{defn}}

保留換行及空格

MediaWiki軟件會遏制單次換行,還會將用空格開始的一行文字轉換成以虛線框包圍的預格式化文字,而HTML也會遏制連續出現的空格,但是這些被遏制的空白通常在詩詞、歌詞、箴言、誓詞和類似文字中卻是應該出現的。Poem擴展添加了類似HTML的<poem>...</poem>標籤,可以保留換行和空格。這組標籤可以在其他標籤裡使用,例如<blockquote>...</blockquote>;也可以指定CSS樣式,例如<poem style="margin-left:2em;">。

代码 效果
<poem>
君不見黃河之水天上來,
 奔流到海不復回?
君不見高堂明鏡悲白髮,
 朝如青絲暮成雪?

人生得意須盡歡,
 莫使金樽空對月。
天生我才必有用,
 千金散盡還復來。
烹羊宰牛且為樂,
 會須一飲三百杯。
岑夫子,丹丘生,
 將進酒,杯莫停。
與君歌一曲,
 請君為我傾耳聽:
鍾鼓饌玉不足貴,
 但願長醉不願醒。
</poem>

君不見黃河之水天上來,
 奔流到海不復回?
君不見高堂明鏡悲白髮,
 朝如青絲暮成雪?

人生得意須盡歡,
 莫使金樽空對月。
天生我才必有用,
 千金散盡還復來。
烹羊宰牛且為樂,
 會須一飲三百杯。
岑夫子,丹丘生,
 將進酒,杯莫停。
與君歌一曲,
 請君為我傾耳聽:
鍾鼓饌玉不足貴,
 但願長醉不願醒。

格式

文字格式

描述 代碼 效果
  • 斜體
  • 粗體
  • small caps(小型大寫字母)
要將''文字變成斜體''的話,可以在文字兩邊各輸入2個引號。

輸入3個引號會使'''文字變成粗體'''。

輸入5個引號會'''''變成粗斜體'''''。

'''''斜體和粗體
這兩種格式'''''只有在同一行內
才會生效。

要將文字變成小型大寫字母{{smallcaps|small caps}}的話,
需要用上[[Help:模板|模板]]。

要將文字變成斜體的話,可以在文字兩邊各輸入2個引號。

輸入3個引號會使文字變成粗體

輸入5個引號會變成粗斜體

斜體和粗體 這兩種格式只有在同一行內 才會生效。

要將文字變成小型大寫字母small caps的話,需要用上模板

可以在正常文字當中添加一小段的代碼。

代碼會用等寬字體顯示。

這個子程式<code>int m2()</code>挺好的。

這個子程式int m2()挺好的。

源代碼可以使用語法突顯

電腦代碼可以用不同顏色顯示,而且有比較嚴格的格式。右邊的示例是子程式int m2()使用了語法突顯後的效果。

<syntaxhighlight lang="cpp">
#include <iostream>
int m2 (int ax, char *p_ax) {
  std::cout <<"Hello World!";
  return 0;
}</syntaxhighlight>
#include <iostream>
int m2 (int ax, char *p_ax) {
  std::cout <<"Hello World!";
  return 0;
}

縮小文字

必要時可以將<small>文字縮小</small>。

用span標籤可以將文字的字體大小
變成<span style="font-size:87%">原來的87%</span>,
以配合圖片標題。

必要時可以將文字縮小

用span標籤可以將文字的字體大小變成原來的87%,以配合圖片標題。

放大文字

最好不要將<big>文字放大</big>,
除非是<small>在一段<big>已縮小的</big>
文字</small>當中這樣做。

最好不要將文字放大,除非是在一段已縮小的文字當中這樣做。

You can include a non-breaking space (sometimes called non-printing character) where you require two words to always appear together on the same line, such as Mr. Smith or 400 km/h, using &nbsp; in place of a regular space between the two "words" that need to behave as a single word (never be separated on different lines).

Mr.&nbsp;Smith or 400&nbsp;km/h

Mr. Smith or 400 km/h

Extra spacing within text can best be achieved using the pad template.

Mary {{pad|4em}} had a little lamb.

Mary   had a little lamb.

Typewriter font

(Also works beyond the end of a paragraph.)

<tt>arrow      &rarr;</tt>

<tt>''italics'', '''bold'''</tt>

<tt>[[link]]

New paragraph </tt>started here.

arrow →

italics, bold

link

New paragraph started here.

Special characters

Egyptian hieroglyphs

WikiHiero is a software extension that renders Egyptian hieroglyphs as PNG images using <hiero> tags.

Example:

代码 效果
<hiero>P2</hiero>
P2

Chess symbols

Diacritical marks

What you type What it looks like
&Agrave; &Aacute; &Acirc; &Atilde; &Auml; &Aring; &AElig;

&Ccedil; &Egrave; &Eacute; &Ecirc; &Euml;

&Igrave; &Iacute; &Icirc; &Iuml; &Ntilde;

&Ograve; &Oacute; &Ocirc; &Otilde; &Ouml; &Oslash; &OElig;

&Ugrave; &Uacute; &Ucirc; &Uuml; &Yuml; &szlig;

&agrave; &aacute; &acirc; &atilde; &auml; &aring; &aelig; &ccedil;

&egrave; &eacute; &ecirc; &euml;

&igrave; &iacute; &icirc; &iuml; &ntilde;

&ograve; &oacute; &ocirc; &otilde; &ouml; &oslash; &oelig;

&ugrave; &uacute; &ucirc; &uuml; &yuml;

À Á Â Ã Ä Å Æ

Ç È É Ê Ë

Ì Í Î Ï Ñ

Ò Ó Ô Õ Ö Ø Œ

Ù Ú Û Ü Ÿ ß

à á â ã ä å æ ç

è é ê ë

ì í î ï ñ

ò ó ô õ ö ø œ

ù ú û ü ÿ

Punctuation, special characters

What you type What it looks like
&iquest; &iexcl; &sect; &para;

&dagger; &Dagger; &bull; &ndash; &mdash;

&lsaquo; &rsaquo; &laquo; &raquo;

&lsquo; &rsquo; &ldquo; &rdquo;

&apos; &quot;

¿ ¡ § ¶

† ‡ • – —

‹ › « »

‘ ’ “ ”

' "

Other punctuation, escaping special characters

The <pre> and <nowiki> markup tags are also available. (For writing "[", "{", "&", "}", "]", for example.)

Commercial symbols

What you type What it looks like
&trade; &copy; &reg; 

&cent; &euro; &yen; &pound; &curren;

™ © ®

¢ € ¥ £ ¤

Subscripts and superscripts

  • The Manual of Style prefers the x<sub>1</sub> format.
  • The latter methods of sub/superscripting cannot be used in the most general context, as they rely on Unicode support which may not be present on all users' machines. For the 1, 2, 3 superscripts, it is nevertheless preferred when possible (as with units of measurement) because most browsers have an easier time formatting lines with it.
Description What you type What it looks like

Subscripts

x<sub>1</sub> x<sub>2</sub> x<sub>3</sub> or

x&#8320; x&#8321; x&#8322; x&#8323; x&#8324;

x&#8325; x&#8326; x&#8327; x&#8328; x&#8329;

x1 x2 x3 or

x₀ x₁ x₂ x₃ x₄

x₅ x₆ x₇ x₈ x₉

Superscripts

x<sup>1</sup> x<sup>2</sup> x<sup>3</sup> or

x&#8304; x&sup1; x&sup2; x&sup3; x&#8308;

x&#8309; x&#8310; x&#8311; x&#8312; x&#8313;

x1 x2 x3 or

x⁰ x¹ x² x³ x⁴

x⁵ x⁶ x⁷ x⁸ x⁹

Combined

&epsilon;<sub>0</sub> = 8.85 &times; 10<sup>&minus;12</sup> C&sup2; / J m

1 [[hectare]] = [[1 E+4 m&sup2;]]

ε0 = 8.85 × 10−12 C² / J m

1 hectare = 1 E+4 m²

Greek characters

What you type What it looks like
&alpha; &beta; &gamma; &delta; &epsilon; &zeta;

&eta; &theta; &iota; &kappa; &lambda; &mu; &nu;

&xi; &omicron; &pi; &rho; &sigma; &sigmaf;

&tau; &upsilon; &phi; &chi; &psi; &omega;

&Alpha; &Beta; &Gamma; &Delta; &Epsilon; &Zeta;

&Eta; &Theta; &Iota; &Kappa; &Lambda; &Mu;

&Nu; &Xi; &Omicron; &Pi; &Rho; &Sigma;

&Tau; &Upsilon; &Phi; &Chi; &Psi; &Omega;

α β γ δ ε ζ

η θ ι κ λ μ ν

ξ ο π ρ σ ς

τ υ φ χ ψ ω

Α Β Γ Δ Ε Ζ

Η Θ Ι Κ Λ Μ

Ν Ξ Ο Π Ρ Σ

Τ Υ Φ Χ Ψ Ω

Mathematical characters

What you type What it looks like
&int; &sum; &prod; &radic;

&minus; &plusmn; &infin;

&asymp; &prop; &equiv; &ne;

&le; &ge;

&times; &middot; &divide; &part;

&prime; &Prime;

&nabla; &permil; &deg; &there4; &alefsym;

&oslash;

&isin; &notin; &cap; &cup;

&sub; &sup; &sube; &supe;

&not; &and; &or; &exist; &forall;

&rArr; &lArr; &dArr; &uArr; &hArr;

&rarr; &darr; &uarr; &larr; &harr;

∫ ∑ ∏ √

− ± ∞

≈ ∝ ≡ ≠

≤ ≥

× · ÷ ∂

′ ″

∇ ‰ ° ∴ ℵ

ø

∈ ∉ ∩ ∪

⊂ ⊃ ⊆ ⊇

¬ ∧ ∨ ∃ ∀

⇒ ⇐ ⇓ ⇑ ⇔

→ ↓ ↑ ← ↔

Mathematical formulae

  • Formulae that include mathematical letters, like x, and operators like × should not use the plain letter x. See math font formatting. For a comprehensive set of symbols, and comparison between <math> tags and the {{math}} template see section TeX vs HTML.
  • The <math> tag typesets using LaTeX markup, which may render as an image or as HTML, depending on environmental settings. The <math> tag is best for the complex formula on its own line in an image format. If you use this tag to put a formula in the line with text, put it in the {{nowrap}} template.
  • The {{math}} template uses HTML, and will size-match a serif font, and will also prevent line-wrap. All templates are sensitive to the = sign, so remember to replace = with {{=}} in template input. Use wikimarkup '' and ''' inside the{{math}} template, as well as other HTML entities. The {{math}} template is best for typeset formulas in line with the text.
代码 效果
<math>2x \times 4y \div 6z + 8
   - \frac {y}{z^2} = 0</math>
{{crlf|}}

{{math|2x &times; 4y &divide;
6z + 8 &minus; {{Fraction
  |y|z<sup>2</sup>}} {{=}} 0}}


<math>\sin 2\pi x + \ln e\,\!</math>
<math>\sin 2\pi x + \ln e</math>
{{math|sin 2&pi;''x'' + ln ''e''}}


2x × 4y ÷ 6z + 8 −

y z2
= 0




sin 2πx + ln e

Spacing in simple math formulae

  • Using &nbsp; to prevent line break is not needed; the {{math}} template will prevent line breaks anyway; you can use <br /> if you need an explicit line break inside a formula.
代码 效果
It follows that {{math
|''x''<sup>2</sup> &ge; 0}} is true when {{mvar|x}} is a real number.

It follows that x2 ≥ 0 is true when x is a real number.

Complicated formulae

  • See Help:Displaying a formula for how to use <math>.
  • A formula displayed on a line by itself should probably be indented by using the colon (:) character.
代码 效果
: <math>\sum_{n=0}^\infty \frac{x^n}{n!}</math>

Links and URLs

Free links

In Wikipedia and some other wikis, free links are used in wikitext markup to produce internal links between pages, as opposed to the concept of CamelCase for the same purpose, which was used in the early days of Wikipedia – see CamelCase and Wikipedia.

In Wikipedia's markup language, you create free links by putting double square brackets around text designating the title of the page you want to link to. Thus, [[Texas]]will be rendered as Texas. Optionally, you can use a vertical bar (|) to customize the link title. For example, typing [[Texas|Lone Star State]] will produce Lone Star State, a link that is displayed as "Lone Star State" but in fact links to Texas.

Link to another wiki article

  • Internally, the first letter of the target page is automatically capitalized and spaces are represented as underscores (typing an underscore in the link has the same effect as typing a space, but is not recommended).
  • Thus the link hereafter is to the Web address en.wikipedia.org/wiki/Public_transport, which is the Wikipedia article with the name "Public transport". See also Canonicalization.
  • A red link is a page that doesn't exist yet; it can be created by clicking on the link.
  • A link to its own page will appear only as bold text.
代码 效果
London has [[public transport]].

London has public transport.

Link to this article: "[[Help:Wiki markup]]" will appear only as bold text.

Link to this article: "Help:Wiki markup" will appear only as bold text.

Renamed link

  • Same target, different name.
  • The target ("piped") text must be placed first, then the text to be displayed second.
What you type What it looks like

New York also has [[public transport|public transportation]].

New York also has public transportation.

Automatically rename links

  • Simply typing the pipe character (|) after a link will automatically rename the link in certain circumstances. The next time you open the edit box you will see the expanded piped link. When previewing your edits, you will not see the expanded form until you press Save and Edit again. The same applies to links to sections within the same page.
  • See Pipe trick for details.
Description What you type What it looks like

Automatically hide stuff in parentheses

[[kingdom (biology)|]]

kingdom

Automatically hide the comma and following text [[Seattle, Washington|]] Seattle

Automatically hide namespace

[[Wikipedia:Village pump|]]

Village pump

Or both

[[Wikipedia:Manual of Style (headings)|]]

Manual of Style

But this doesn't work for section links

[[Wikipedia:Manual of Style#Links|]]

[[Wikipedia:Manual of Style#Links|]]

Blend link

  • Endings are blended into the link.
    • Exception: a trailing apostrophe (') and any characters following the apostrophe are not blended.
  • Preferred style is to use this instead of a piped link, if possible.
  • Blending can be suppressed by using the <nowiki /> tag, which may be desirable in some instances.
Description What you type What it looks like

Blending active

San Francisco also has [[public transport]]ation. Examples include [[bus]]es, [[taxicab]]s, and [[tram]]s.

San Francisco also has public transportation. Examples include buses, taxicabs, and trams.

Blending suppressed

A [[micro-]]<nowiki />second.

A micro-second

Link to a section of a page

  • The part after the hash sign (#) must match a section heading on the page. Matches must be exact in terms of spelling, case, and punctuation. Links to non-existent sections are not broken; they are treated as links to the beginning of the page.
  • Include "| link title" to create a stylish (piped) link title.
  • If sections have the same title, add a number to link to any but the first. #Example section 3 goes to the third section named "Example section". You can use the pipe and retype the section title to display the text without the # symbol.
What you type What it looks like

[[Wikipedia:Manual of Style#Italics]] is a link to a section within another page.

Wikipedia:Manual of Style#Italics is a link to a section within another page.

[[#Links and URLs]] is a link to another section on the current page. [[#Links and URLs|Links and URLs]] is a link to the same section without showing the # symbol.

#Links and URLs is a link to another section on the current page. Links and URLs is a link to the same section without showing the # symbol.

[[Wikipedia:Manual of Style#Italics|Italics]] is a piped link to a section within another page.

Italics is a piped link to a section within another page.

Create page link

  • To create a new page:
    1. Create a link to it on some other (related) page.
    2. Save that page.
    3. Click on the link you just made. The new page will open for editing.
  • For more information, see starting an article and check out Wikipedia'snaming conventions.
  • Please do not create a new article without linking to it from at least one other article.
Description What you type What it looks like

Links to pages that don’t exist yet look red.

The article about [[cardboard sandwiches]] doesn't exist yet.

The article about cardboard sandwiches doesn't exist yet.

Redirects

  • Redirect one article title to another by placing a directive like the one shown to the right on thefirst line of the article (such as at a page titled "USA").
  • It is possible to redirect to a section. For example, a redirect to United States#History will redirect to the History section of the United States page, if it exists.
Description What you type

Redirect to an article

#REDIRECT [[United States]]

Redirect to a section

#REDIRECT [[United States#History]]

Link to another namespace

What you type What it looks like

See the [[Wikipedia:Manual of Style]].

See the Wikipedia:Manual of Style.

Link to the same article in another language (interlanguage links)

  • To link to a corresponding page in another language, use the form: [[language code:Foreign title]].
  • It is recommended interlanguage links be placed at the very end of the article.
  • Interlanguage links are not visible within the formatted article, but instead appear as language links on the sidebar (to the left) under the menu section "languages".
Description What you type

Link from English article "Plankton" to the Spanish article "Plancton".

"es" is the language code for "español" (the Spanish language).

[[es:Plancton]]

Other examples: French (fr for français), German (de for Deutsch), Russian (ru), and simple English (simple).

[[fr:Plancton]]
[[de:Plankton]]
[[ru:Планктон]]
[[simple:Plankton]]

Interwiki link

Description What you type What it looks like

Linking to a page on another wiki in English.

All of these forms lead to the URL http://en.wiktionary.org/wiki/Hello.

Simple link.

Without prefix.

Named link.

[[Wiktionary:Hello]]

[[Wiktionary:Hello|]]

[[Wiktionary:Hello|Wiktionary definition of "Hello"]]

Wiktionary:Hello

Hello

Wiktionary definition of "Hello"

Linking to a page on another wiki in another language.

All of these forms lead to the URL http://fr.wiktionary.org/wiki/bonjour.

Simple link.

Without prefix.

Named link.

[[Wiktionary:fr:bonjour]]

[[Wiktionary:fr:bonjour|]]

[[Wiktionary:fr:bonjour|bonjour]]

Wiktionary:fr:bonjour

fr:bonjour

bonjour

Categories

  • To put an article in a category, place a link like [[Category:Example]] into the article. As with interlanguage links, placing these links at the end of the articleis recommended.
  • To link to a category page without putting the article into the category, use a colon prefix (":Category") in the link.
Description What you type What it looks like

Categorize an article.

[[Category:Character sets]]

Link to a category.

[[:Category:Character sets]]

Category:Character sets

Without prefix.

[[:Category:Character sets|]]

Character sets

External links

  • Square brackets indicate an external link. Note the use of a space (not a pipe) to separate the URL from the link text in the "named" link. Square brackets may be used as normal when not linking to anything – [like this].
  • A URL must begin with a supported URI scheme: http:// andhttps:// will be supported by all browsers; irc://, ircs://, ftp://,news://, mailto: and gopher:// will require a plugin or an external application. IPv6 addresses in URLs are currently not supported.
  • A URL containing certain characters will display and link incorrectly unless those characters are encoded. For example, a space must be replaced by %20. Encoding can be achieved by:
  • Use the link button on the enhanced editing toolbar to encode the link; this tool will add the bracket markup and the linked text, which may not always be desirable.
  • Or manually encode the URL by replacing these characters:
space " , ' ; < > ? [ ]
%20 %22 %2c %27 %3b %3c %3e %3f %5b %5d
  • Or use the {{urlencode:}} magic word. See Help:Magic words in the MediaWiki documentation for more details.
Description What you type What it looks like

Named link with an external link icon

[http://www.wikipedia.org Wikipedia]

Wikipedia

Unnamed link

(Only used within article body for footnotes)

[http://www.wikipedia.org]

[1]

Bare URL

(Bad style)

http://www.wikipedia.org

http://www.wikipedia.org

Link without arrow

(Not often used)

<span class="plainlinks">[http://www.wikipedia.org Wikipedia]</span>

Wikipedia

Miscellaneous

"As of" tag

  • "As of" tags generate phrases like "As of April 2009" or "as of April 2009", and categorize info that will need updating. For an explanation of the parameters see template documentation.
What you type What it looks like

{{As of|2009|4|df=us}}

截至2009年4月 (2009-04)

{{As of|2009|4|df=us|lc=y}}

截至2009年4月 (2009-04)

Media link

  • To include links to non image uploads such as sounds, use a "media" link. For images, see next section.
  • Some uploaded sounds are listed at Commons:Sound.
What you type What it looks like

[[media:Classical guitar scale.ogg|Sound]]

Sound

Links directly into edit mode

Description What you type What it looks like

Full URL

{{fullurl:Help:Wiki markup|action=edit}}

//zh.wikipedia.org/w/index.php?title=Help:Wiki_markup&action=edit

"Edit" label

{{edit}}

[编辑]

Automatic links

Book sources
  • Link to books using their ISBN, which creates a link to Special:BookSources. This is preferred to linking to a specific online bookstore, because it gives the reader a choice of vendors. However, if one bookstore or online service provides additional free information, such as table of contents or excerpts from the text, then a link to that source will aid the user and is recommended. ISBN links do not need any extra markup, provided you use one of the indicated formats.
  • To create a link to Special:BookSources using alternative text (e.g. the book's title), use the internal link style with the appropriate namespace.
What you type What it looks like

ISBN 012345678X

ISBN 012345678X

ISBN 0-12-345678-X

ISBN 0-12-345678-X

Link to a book using [[Special:BookSources/0670037818|alternative text, such as its title]]

Link to a book using alternative text, such as its title

RFC number
What you type What it looks like

Text mentioning an RFC number anywhere, e.g. RFC 4321.

Text mentioning an RFC number anywhere, e.g. RFC 4321.

Links partially italicized
What you type What it looks like

[[Hindenburg disaster|''Hindenburg'' disaster]]

Hindenburg disaster

Pronunciation aids

It is often desirable to provide an aid to pronunciation for a word. The IPAc-en andRespell templates can be of assistance.

What you type What it looks like

'''Konjac''' {{IPAc-en|lang|pron|ˈ|k|oʊ|n|j|æ|k}}

Konjac 英語 發音: /ˈknjæk/

'''Konjac''' ({{IPAc-en|lang|pron|ˈ|k|oʊ|n|j|æ|k}} {{respell|KOHN|yak}})

Konjac (英語 發音: /ˈknjæk/ KOHN-yak)

''Konjac'' is pronounced {{IPAc-en|ˈ|k|oʊ|n|j|æ|k}} in English.

Konjac is pronounced /ˈknjæk/ in English.

Refer to Wikipedia:Manual of Style (pronunciation) for more information.

Musical notation

Musical notation is added by using the <score>……</score> extension tag. For example:

代码 效果
<score>\relative c' { fis d fis a d f e d c cis d e a g f ees }</score>
\relative c' { fis d fis a d f e d c cis d e a g f ees }

Images

Only images that have been uploaded to Wikipedia can be used. To upload images, use the upload page. You can find the uploaded image on the image list.

What you type What it looks like Notes
A picture: 
[[File:wiki.png]]
A picture:

With alternative text: 
[[File:wiki.png|alt=Puzzle globe logo]]
With alternative text:

Puzzle globe logo

  • Alternative text, used when the image is unavailable or when the image is loaded in a text-only browser, or when spoken aloud, is strongly encouraged. See Alternative text for images for help on choosing it.
With link: 
[[File:wiki.png|link=Wikipedia]]
With link:


  • The link directs to a page, Wikipedia, instead of the file.
Floating to the right side of the page using the ''frame'' attribute and a caption: 
[[File:wiki.png|frame|alt=Puzzle globe|Wikipedia logo]]
Floating to the right side of the page using the frame attribute and a caption:
Puzzle globe
Wikipedia logo

  • The frame tag automatically floats the image right.
  • The last parameter is the caption that appears below the image.
Floating to the right side of the page using the ''thumb'' attribute and a caption: 
[[File:wiki.png|thumb|alt=Puzzle globe|Wikipedia logo]]
Floating to the right side of the page using the thumb attribute and a caption:
Puzzle globe
Wikipedia logo

  • The thumb tag automatically floats the image right.
  • An enlarge icon is placed in the lower right corner.
Floating to the right side of the page ''without'' a caption: 
[[File:wiki.png|right|Wikipedia encyclopedia]]
Floating to the right side of the page without a caption:
Wikipedia encyclopedia
Wikipedia encyclopedia
A picture resized to 30 pixels... 
[[File:wiki.png|30 px|Wikipedia encyclopedia]]
A picture resized to 30 pixels...

Wikipedia encyclopedia

Linking directly to the description page of an image: 
[[:File:wiki.png]]
Linking directly to the description page of an image:

File:wiki.png

  • Clicking on an image displayed normally on a page also leads to the description page.
Linking directly to an image without displaying it: 
[[Media:wiki.png|Image of jigsaw globe]]
Linking directly to an image without displaying it:

Image of jigsaw globe

  • To include links to images shown as links instead of drawn on the page, use a "media" link.
Example: 
<div style="display: inline; width: 220px; float: right;">
Place images here </div>

Example:

Place images here

Using the span or div elements to separate images from text (note that this may allow images to cover text).

Example:

{| align=right
|-
|
Place images here
|}

Example:

Place images here

Using wiki markup to make a table in which to place a vertical column of images (this helps edit links match headers, especially in Firefox browsers).

See the Wikipedia's image use policy as a guideline used on Wikipedia.

For further help on images, including some more versatile abilities, see the picture tutorial.

Tables

There are two ways to build tables:

  • In special wiki-markup (see Help:Table).
  • Using HTML elements: <table>, <tr>, <td> or <th>.

See also When tables are appropriate.

References and citing sources

Making a reference citing a printed or online source can be accomplished by using the <ref>...</ref> tags. Inside these tags details about the reference are added.

Details about the citation can be provided using a structure provided by various templates; the table below lists some typical citation components.

What it's for What you type
To create the reference <ref name="name for reference">Use a closing tag</ref>
To cite a book {{cite book}}
To cite a web source {{cite web}}
Book ISBN |isbn=0-4397-0818-4 (ISBN of the book)
Web URL |url=http://www.wikipedia.org
Title |title=title of source
Author |author=authors, use commas for multiple
First name |first=first name
Last name |last=last name
Location |location=location of publisher
Publisher |publisher=who published the source
Date |date=2007-09-21 (date of source)
Year |year=year of source
Accessed date |accessdate=2008-12-25
A complete reference tag <ref name="WikiMarkup">{{cite web |url=http://en.wikipedia.org/w/index.php?title=Help:Wiki_markup |title=Help:Wiki markup |publisher=Wikimedia Foundation}}</ref>
Referencing this again <ref name="WikiMarkup" />
Citation needed {{citation needed}}

Templates and transcluding pages

Examples for templates: {{pad|...}}, {{math|...}}, {{as of|...}}, {{edit}}

Templates are segments of wiki markup that are meant to be copied automatically ("transcluded") into a page. You add them by putting the template's name in {{double braces}}. It is also possible to transclude other pages by using {{:colon and double braces}}.

There are three pairs of tags that can be used in wikitext to control how transclusion affects parts of a template or article. They determine whether or not wikitext renders, either in its own article, which we will call "here", or in another article where it is transcluded, which we will call "there".

  • <noinclude>: the content will not be rendered there. These tags have no effect here.
  • <includeonly>: the content will render only there, and will not render here(like invisible ink made visible by means of transclusion).
  • <onlyinclude>: the content will render here and will render there, but it will only render there what is between these tags.

There can be several such section "elements". Also, they can be nested. All possible renderings are achievable. For example, to render there one or more sections of the page here use <onlyinclude> tags. To append text there, wrap the addition in <includeonly> tags before, within, or after the section. To omit portions of the section, nest <noinclude> tags within it.

If a page is transcluded without transclusion markup, it may cause an unintentionalcategorization. Any page transcluding it will contain the same category as the original page. Wrap the category markup with <noinclude> tags to prevent incorrect categorization.

Some templates take parameters, as well, which you separate with the pipe character |.

What you type What it looks like
{{Transclusion demo}}

Template:Transclusion demo

{{Help:Transclusion demo}}

Help:Transclusion demo

This template takes two parameters,
and creates underlined text with a
hover box for many modern browsers
supporting CSS:

{{SetTitle|This is the hover text|
Hover your mouse over this text}}

Go to this page to see the H:title
template itself: {{tl|H:title}}

This template takes two parameters, and creates underlined text with a hover box for many modern browsers supporting CSS:

Hover your mouse over this text

Go to this page to see the H:title template itself: {{H:title}}

Talk and project pages

Signing comments

  • The character tilde (~) is used when adding a comment to a Talk page.
  • Your username provides a link to your user page.
Description What you type What it looks like

You should sign your comments by appending four tildes to the comment, which adds your user name plus date/time.

~~~~

Username (talk) 13:29, 28 3月 2024(UTC)

Adding three tildes will add just your user name.

~~~

Username (talk)

Adding five tildes gives the date/time alone.

~~~~~

13:29, 28 3月 2024 (UTC)

What links here and related changes

What you type What it looks like

[[Special:WhatLinksHere/aaa]]

Special:WhatLinksHere/aaa

[[Special:RecentChangesLinked/aaa]]

Special:RecentChangesLinked/aaa

Linking to old revisions of pages, diffs, and specific history pages

  • External link function is mainly used for these.
  • Open an old revision or diff and copy the URL from the address bar, pasting it where you want it.
What you type What it looks like

[http://en.wikipedia.org/w/index.php?title=Help:Wiki_markup&diff=330350877&oldid=330349143 Diff between revisions 330349143 and 330350877]

Diff between revisions 330349143 and 330350877

  • For an old revision, you can also use a permalink. Though here only the main text is guaranteed to be retained (images and templates will be shown as they are today, not as they were at the time).
What you type What it looks like

[[Special:Permalink/330350877|Revision 330350877]]

Revision 330350877

User edits

  • Link to a user's Contributions page.
Description What you type What it looks like
Username (registered users). [[Special:Contributions/UserName]] Special:Contributions/UserName
IPv4 address (unregistered users). [[Special:Contributions/192.0.2.0]] Special:Contributions/192.0.2.0
IPv6 address (unregistered users). [[Special:Contributions/2001:0db8:0000:0000:0000:ff00:0042:8329]] Special:Contributions/2001:0db8:0000:0000:0000:ff00:0042:8329

Coloring text

What you type What it looks like

I will change the color in {{color|blue|the middle part of}} this sentence.

I will change the color in the middle part of this sentence.

Highlighting text

What you type What it looks like

This is how to {{Font color||yellow|highlight}} part of a sentence.

This is how to highlight part of a sentence.

Show deleted or inserted text

  • When editing regular Wikipedia articles, just make your changes and do not mark them up in any special way.
  • When editing your own previous remarks in talk pages, it is sometimes appropriate to mark up deleted or inserted content.
    • To indicate deleted content use <del>...</del>.
    • To indicate inserted content use <ins>...</ins>.
代码 效果
You can <del>strike out deleted content</del> and <ins>underline new content</ins>.

You can strike out deleted content and underline new content.

Limiting formatting / escaping wiki markup

A few different kinds of formatting will tell the wiki to display things as you typed them – what you see is what you get!

What you type What it looks like
'''&lt;nowiki&gt; tag:'''

<nowiki>
The nowiki tag ignores [[wiki]]
''markup''. It reformats text by
removing newlines and multiple
spaces. It still interprets
characters specified by
&name;: &rarr;
</nowiki>

<nowiki> tag:

The nowiki tag ignores [[wiki]] ''markup''. It reformats text by removing newlines and multiple spaces. It still interprets characters specified by &name;: &rarr;

'''&lt;pre&gt; tag:'''

<pre>The <pre> tag ignores [[wiki]]
''markup'' as does the <nowiki>
tag. Additionally, <pre> displays
in a mono-spaced font, and does
not  reformat    text    spaces.
It still interprets special
characters: &rarr;
</pre>

<pre> tag:

The <pre> tag ignores [[wiki]]
''markup'' as does the <nowiki>
tag. Additionally, <pre> displays
in a mono-spaced font, and does
not  reformat    text    spaces.
It still interprets special
characters: →
'''[Text without a URL]:'''

Single square brackets holding
[text without a HTTP URL] are
preserved, but single square
brackets containing a URL are
treated as being an external
[http://example.com/ Web link].

[Text without a URL]:

Single square brackets holding [text without a HTTP URL] are preserved, but single square brackets containing a URL are treated as being an external Web link.

'''Leading space:'''

Leading spaces are another way
to preserve formatting.
 Putting a space at the
 beginning of each line
 stops the text   from
 being reformatted.
 It still interprets [[wiki]] ''markup'' and special characters: &rarr;

Leading space:

Leading spaces are another way to preserve formatting.

Putting a space at the
beginning of each line
stops the text   from
being reformatted.
It still interprets wiki markup and special characters: →

Nowiki

<nowiki>...</nowiki> and <nowiki /> tags stop parsing of wiki markup, except HTML character entity references (e.g. for special characters). Unlike <pre>, "nowiki" doesn't change formatting.

An example of <nowiki>...</nowiki>:

代码 效果
<nowiki>{{cite book}}</nowiki>

{{cite book}}

(However in this particular case probably you prefer {{tl|cite book}} to create a link as {{cite book}}, or{{tlf|cite book}} prints {{cite book}}.)

A singular <nowiki /> can be used to break wikimarkup.

  • Markup such as *, #, ; and : only and always take effect at the beginning of a line. A<nowiki /> before the markup will cause the characters to not parse as markup.
  • An internal link immediately followed by characters are blended to form a single link. Where this is not desired, add a<nowiki /> after the link.
  • HTML(-like) tags can be stopped parsing by inserting <nowiki /> after the opening angle bracket.
<nowiki /> examples
代码 效果
* Unordered list

  • Unordered list
<nowiki />* Unordered list

* Unordered list

A [[micro-]]second.

A micro-second.

A [[micro-]]<nowiki />second.

A micro-second.

'<nowiki />'We don't want italics.'<nowiki />'

''We don't want italics.''

[[<nowiki />Example]]

[[Example]]

[<nowiki />[[Example]]]
No <<nowiki />br />line break. But for tag pairs, you need nowiki for the closing tag, too. <<nowiki />pre>The following /pre is gone!</pre>
No <br />line break. But for tag pairs, you need nowiki for the closing tag, too. <pre>The following /pre is gone!

If you want to write tags, {{tag}} template is handy. E.g. {{tag|nowiki}} prints <nowiki>...</nowiki>.

HTML entities

<nowiki> and <pre> parse HTML entities. If you want to escape this, replace & with &amp;.

代码 效果
<nowiki>&amp;</nowiki>

&

<nowiki>&lt;</nowiki>

<

<nowiki>&amp;amp;</nowiki>

&amp;

<nowiki>&amp;lt;</nowiki>

&lt;

Use in templates

When used in a template, <nowiki> simply does not work as you may expect.

  • Including <nowiki> immediately acts upon the enclosed markup. Attempting to escape or transclude the brackets causes <nowiki /> to not work at all.
  • Using #tag:nowiki works, but has major limitations:
    • Templates, parameters, parser functions, and parser magic such as signatures are parsed, not nowikied.
    • Included <ref> tags will expose the strip markers.
代码 效果
<nowiki>{{tl|cite book}}</nowiki>

{{tl|cite book}}

{{#tag:nowiki|{{tl|cite book}}}}

{{[[Template:cite book|cite book]]}}

{{#tag:nowiki|<ref>Text</ref>}}
{{reflist}}

[1]

  1. ^ Text

Pre

<pre> is a parser tag that emulates the HTML <pre> tag. It defines preformatted text that is displayed in a fixed-width font and is enclosed in a dashed box. HTML and wiki markups are escaped and spaces and line breaks are preserved, but HTML entities are parsed.

<pre> examples
代码 效果
<pre><!--Comment-->

[[wiki]] markup &amp;</pre>
<!--Comment-->

[[wiki]] markup &

<pre> formatted text does not wrap, thus text may extend past the browser window:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

To resolve this, <pre> may use CSS styling to add wrapping or a horizontal scrollbar:

  • Wrapping: <pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">
  • Scroll bar: <pre style="overflow:auto; width:auto;">

Alternatively, consider using {{pre2}} template or <syntaxhighlight enclose="div" lang="text">……</syntaxhighlight>.

Invisible text (comments)

It's uncommon – but on occasion acceptable for notes to other editors – to add a hidden comment within the text of an article. These comments are only visible when editing or viewing the source of a page. Most comments should go on the appropriate Talk page. The format is to surround the hidden text with "<!--" and "-->" and may cover several lines, e.g.:

<!-- An example of hidden comments
 This won't be visible except in "edit" mode. -->

Another way to include a comment in the wiki markup uses the {{Void}} template, which can be abbreviated as {{^}}. This template "expands" to the empty string, generating no HTML output; it is visible only to people editing the wiki source. Thus {{^|A lengthy comment here}} operates similarly to the comment <!-- A lengthy comment here -->. The main difference is that the template version can be nested, while attempting to nest HTML comments produces odd results.

Variables

命名空间
基本命名空间 讨论命名空间
0 主/條目 帮助 讨论 1
2 用戶 帮助 用户讨论 3
4 计划 计划讨论 5
6 文件 帮助 文件讨论 7
8 MediaWiki MediaWiki讨论 9
10 模板 帮助 模板讨论 11
12 帮助 帮助讨论 13
14 分类 帮助 分类讨论 15
100 主题 主题讨论 101
102 維基專題 帮助 維基專題討論 103
118 草稿 草稿讨论 119
710 字幕 字幕討論 711
828 模块 模块讨论 829
2300 小工具 小工具讨论 2301
2302 小工具定義頁 小工具定義頁讨论 2303
2600 话题 帮助
虚拟命名空间
-1 特殊
-2 媒体
Code Effect Notes
{{CURRENTWEEK}} 13
{{CURRENTDOW}} 4

Monday = 1, Tuesday = 2, etc., but Sunday = 0

{{CURRENTMONTH}} 03
{{CURRENTMONTHNAME}} 3月
{{CURRENTMONTHNAMEGEN}} 3月
{{CURRENTDAY}} 28
{{CURRENTDAYNAME}} 星期四
{{CURRENTYEAR}} 2024
{{CURRENTTIME}} 13:29
{{NUMBEROFARTICLES}} 1,411,597
{{NUMBEROFPAGES}} 7,664,650
{{NUMBEROFUSERS}} 3,490,416
{{PAGENAME}} Liflon/Help:維基代碼
{{NAMESPACE}} User
{{REVISIONID}} -
{{REVISIONUSER}} Antigng
{{localurl:pagename}} /wiki/Pagename
{{localurl:Wikipedia:Sandbox|action=edit}} /w/index.php?title=Wikipedia:Sandbox&action=edit
{{fullurl:pagename}} //zh.wikipedia.org/wiki/Pagename
{{fullurl:pagename|query_string}} //zh.wikipedia.org/w/index.php?title=Pagename&query_string
{{SERVER}} //zh.wikipedia.org
{{ns:1}} Talk

{{ns:index}} e.g. {{ns:1}} → full name of namespace

{{SITENAME}} Wikipedia

{{NUMBEROFARTICLES}} is the number of pages in the main namespace which contain a link and are not a redirect. This includes full articles, stubs containing a link, and disambiguation pages.

{{CURRENTMONTHNAMEGEN}} is the genitive (possessive) grammatical form of the month name, as used in some languages but not in English; {{CURRENTMONTHNAME}} is the nominative (subject) form, as usually seen in English.

In languages where it makes a difference, you can use constructs like {{grammar:case|word}} to convert a word from the nominative case to some other case. For example, {{grammar:genitive|{{CURRENTMONTHNAME}}}} means the same as {{CURRENTMONTHNAMEGEN}}.

HTML

Many HTML tags can be used in wiki markup. You can check your HTML by using markup validation.