用户: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) 06:52, 18 4月 2024(UTC)

Adding three tildes will add just your user name.

~~~

Username (talk)

Adding five tildes gives the date/time alone.

~~~~~

06:52, 18 4月 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}} 16
{{CURRENTDOW}} 4

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

{{CURRENTMONTH}} 04
{{CURRENTMONTHNAME}} 4月
{{CURRENTMONTHNAMEGEN}} 4月
{{CURRENTDAY}} 18
{{CURRENTDAYNAME}} 星期四
{{CURRENTYEAR}} 2024
{{CURRENTTIME}} 06:52
{{NUMBEROFARTICLES}} 1,414,683
{{NUMBEROFPAGES}} 7,681,059
{{NUMBEROFUSERS}} 3,499,570
{{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.