Wikipedia:Wikicode

Help:Wikitext

Help:Wikitext


The markup language called wikitext, also known as wiki markup or wikicode, consists of the syntax and keywords used by the MediaWiki software to format a page. (Note the lowercase spelling of these terms.[lower-alpha 1]) To learn how to see this hypertext markup, and to save an edit, see Help:Editing. Generally, coding can be copied and pasted, without writing new code. There is a short list of markup and tips at Help:Cheatsheet.

In addition to wikitext, some HTML elements are also allowed for presentation formatting. See Help:HTML in wikitext for information on this.

Layout

Sections

Article sections in a page will follow that page's lead or introduction and, if there are four or more, the table of contents.

Section headings

The = through ====== markup are headings for the sections with which they are associated.

  • A single = is styled as the article title and should not be used within an article.
  • Headings are styled through CSS and add an [edit] link. See this section for the relevant CSS.
  • Four or more headings cause a table of contents to be generated automatically.
  • Do not use any markup after the final heading markup – this will either break the heading, or will cause the heading to not be included in an edit summary.
More information Markup, Renders as ...

Templates: {{fake heading}} for use in documentation.

Horizontal rule

The horizontal rule represents a paragraph-level thematic break. Do not use in article content, as rules are used only after main sections, and this is automatic.

More information Markup, Renders as ...

HTML equivalent: <hr /> (which can be indented, whereas ---- always starts at the left margin.)

Table of contents

When a page has at least four headings, a table of contents (TOC) will automatically appear after the lead and before the first heading. The TOC can be controlled by magic words or templates:

  • __FORCETOC__ forces the TOC to appear at the normal location regardless of the number of headings.
  • __TOC__ forces the TOC to appear at the point where the magic word is inserted instead of the normal location.
  • __NOTOC__ disables the TOC entirely.
  • {{TOC limit}} template can be used to control the depth of subsections included in the TOC. This is useful where the TOC is long and unwieldy.
  • Category:Wikipedia table of contents templates contains a number of specialized TOC templates.

Line breaks

Line breaks or newlines are used to add whitespace between lines, such as separating paragraphs.

  • A line break that is visible in the content is inserted by pressing ↵ Enter twice.
    • It's good practice to do this by itself when publishing changes. Leave additional changes to another edit because otherwise only the line break will be highlighted in the diff.
  • Pressing ↵ Enter once will place a line break in the markup, but it will not show in the rendered content, except when using list markup.
  • Markup such as bold or italics will be terminated at a line break.
  • Blank lines within indented wikitext should not be added due to accessibility issues.
More information Markup, Renders as ...

HTML equivalent: <br> or <br /> can be used to break line layout.

Templates for line breaks:

  • {{break}} can add multiple line breaks.
  • {{-}} and {{clear}} adds a break with styling, to clear floating elements. Often used to prevent text from flowing next to unrelated tables or images.

Unbulleted list:

Indent text

Indentation is most commonly used on talk pages.

More information Markup, Renders as ...

Templates: {{outdent}}, {{outdent2}}

Blockquote

When there is a need for separating a block of text. This is useful for (as the name says) inserting blocks of quoted (and cited) text.

More information Markup, Renders as ...

This uses an HTML tag; template {{quote}} results in the same render.

Center text

More information Markup, Renders as ...

Template {{center}} uses the same markup. To center a table, see Help:Table#Centering tables. Please do not use <center>...</center> tags, as it is obsolete.

Align text to right

You can align content in a separate container:

More information Markup, Renders as ...

Or; make the text float around it:

More information Markup, Renders as ...

Lists

Do not leave blank lines between items in a list unless there is a reason to do so, since this causes the MediaWiki software to interpret each item as beginning a new list.

Unordered lists

More information Markup, Renders as ...

Ordered lists

More information Markup, Renders as ...

Description lists

To list terms and definitions, start a new line with a semicolon (;) followed by the term. Then, type a colon (:) followed by a definition. The format can also be used for other purposes, such as make and models of vehicles, etc.

Description lists (formerly definition lists, and a.k.a. association lists) consist of group names corresponding to values. Group names (terms) are in bold. Values (definitions) are indented. Each group must include one or more definitions. For a single or first value, the : can be placed on the same line after ; – but subsequent values must be placed on separate lines.

Do not use a semicolon (;) simply to bold a line without defining a value using a colon (:). This usage renders invalid HTML5 and creates issues with screen readers. Also, use of a colon to indent (other than for talk page responses) may also render invalid HTML5 and cause accessibility issues per MOS:INDENTGAP.

More information Markup, Renders as ...

HTML equivalent: <dl> <dt>...</dt>, <dd>...</dd> </dl>

Templates: {{defn}}

Retaining newlines and spaces

The MediaWiki software suppresses single newlines and converts lines starting with a space to preformatted text in a dashed box. HTML suppresses multiple spaces. It is often desirable to retain these elements for poems, lyrics, mottoes, oaths and the like. The Poem extension adds HTML-like <poem>...</poem> tags to maintain newlines and spaces. These tags may be used inside other tags such as <blockquote>...</blockquote>; the template {{poemquote}} provides a convenient shorthand. CSS styles may be applied to this tag, e.g.: <poem style="margin-left: 2em;">.

More information Markup, Renders as ...

Poems and their translation can be presented side by side, and the language can be indicated with lang="xx". Following the last side-by-side block, {{Clear|left}} must be used to cancel "float:left;" and to re-establish normal flow. Note that this method does not require a table and its columns to achieve the side-by-side presentation.

Markup

<poem lang="fr" style="float:left;">Frère Jacques, frère Jacques,
Dormez-vous? Dormez-vous?
Sonnez les matines! Sonnez les matines!
Ding, dang, dong. Ding, dang, dong.</poem>
<poem style="margin-left:2em; float:left;">Are you sleeping? Are you sleeping?
Brother John, Brother John,
Morning bells are ringing! Morning bells are ringing!
Ding, dang, dong. Ding, dang, dong.</poem>{{Clear|left}}

Renders as

Frère Jacques, frère Jacques,
Dormez-vous? Dormez-vous?
Sonnez les matines! Sonnez les matines!
Ding, dang, dong. Ding, dang, dong.

Are you sleeping? Are you sleeping?
Brother John, Brother John,
Morning bells are ringing! Morning bells are ringing!
Ding, dang, dong. Ding, dang, dong.

Format

Text formatting

More information Description, What you type ...

Special characters

Special characters can often be displayed using numeric character references or character entity references. See Character encodings in HTML for more information. For example, &Agrave; and &#xC0; both render À (A-grave). Percent-encoding can't be used, as it works only in URLs.

Diacritical marks

Diacritic marks, using character entity references.

More information What you type, What it looks like ...

Punctuation special characters

Using character entity references.

More information What you type, What it looks like ...

Escaping punctuation characters

The <pre>, <nowiki>, and <code> markup tags are also available, for writing "[", "{", "&", "}", "]" for example. These tags prevent these characters from being recognised as wiki markup, which is a possibility in some circumstances.

Commercial symbols

Using character entity references.

More information What you type, What it looks like ...

Greek characters

Using character entity references.

More information What you type, What it looks like ...

Egyptian hieroglyphs

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

Example:

More information Markup, Renders as ...

Chess symbols

For example, &#9812; displays

Subscripts and superscripts

  • The Manual of Style prefers the <sub> and <sup> formats, for example x<sub>1</sub>. So this should be used under most circumstances.
  • The latter methods of sub/superscripting cannot be used in the most general context, as they rely on Unicode support that may not be present on all users' machines.
More information Description, What you type ...

Characters in the Private Use Area, and invisible formatting characters

Invisible and PUA (Private Use Areas) characters should be avoided where possible. When needed, they should both be replaced with their (hexa)decimal code values (as "&#(x)...;"). This renders invisible characters visible, for manual editing, and allows AWB to process pages with PUA characters. The latter should also be tagged with the {{PUA}} template for tracking and future maintenance.

Mathematical characters and formulae

Mathematical characters

More information What you type, What it looks like ...

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,[lower-alpha 2] 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, or start the input with 1=. Use wiki markup '' and ''' inside the {{math}} template, as well as other HTML entities. The {{math}} template is best for typeset formulas in line with the text.
More information , ...

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.
More information Markup, Renders as ...

Complicated formulae

  • See Help:Displaying a formula for how to use <math>.
  • A formula displayed on a line by itself should be indented using <math display=block>...</math>
More information Markup, Renders as ...

Indenting by using the colon (:) character (i.e. using :<math></math> instead of <math display=block></math>) is discouraged for accessibility reasons.

Wikilinks are used in wikitext markup to produce internal links between pages. You create wikilinks 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.
More information Markup, Renders as ...
  • Same target, different name.
  • The target ("piped") text must be placed first, then the text to be displayed second.
More information What you type, What it looks like ...
  • 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.
More information Description, What you type ...
  • 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.
More information Description, What you type ...
  • 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.
More information What you type, What it looks like ...
  • 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's naming conventions.
  • Please do not create a new article without linking to it from at least one other article.
More information Description, What you type ...

Redirects

  • Redirect one article title to another by placing a directive like the one shown to the right on the first line of the article (such as at a page titled "US").
  • 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.
More information Description, What you type ...
  • The full page name should be included in double square brackets.
More information What you type, What it looks like ...

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".
More information Description, What you type ...
More information Description, What you type ...

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 article is recommended.
  • To link to a category page without putting the article into the category, use a colon prefix (":Category") in the link.
More information Description, What you type ...
  • Single-square brackets indicate an external link. Note the use of a space (not a pipe |) to separate the URL from the link text in a named link. Square brackets may be used as normal punctuation when not linking to anything – [like this].
  • A URL must begin with a supported URI scheme: https:// (preferably) and http:// 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 percent 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:
More information space, " ...
  • Or use the {{urlencode:}} magic word. See Help:Magic words in the MediaWiki documentation for more details.
More information Description, What you type ...

Miscellaneous

  • 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.
More information What you type, What it looks like ...
  • These create links that directly go to the edit or view source tab. For example, to create links to the edit tab for this page, either of the following works:
More information Description, What you type ...
  • Linking to a page with a title containing words that are usually italicized, such as the Hindenburg disaster article.
More information What you type, What it looks like ...

Musical notation

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

More information Markup, Renders as ...

Images

Only images that have been uploaded to Wikipedia or Wikimedia Commons can be used. To upload images, use the Commons upload wizard for photos you have taken, and the Wikipedia upload page if there may be copyright issues. You can find the uploaded image on the image list.

See the Wikipedia's image use policy for the policy used on Wikipedia.

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

More information What you type, What it looks like ...

Tables

There are two ways to build tables:

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

Columns

Use {{colbegin}} and {{colend}} templates to produce columns.

References and citing sources

Making a reference citing a printed or online source can be accomplished by using the <ref> wiki markup 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.

More information What it's for, What you type ...

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. They are specified by putting the template's name in {{double braces}}. Most templates are pages in the Template namespace, but it is possible to transclude mainspace pages (articles) 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 unintentional categorization. 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 |.

More information What you type, What it looks like ...

Talk and project pages

These are likely to be helpful on talk and project pages.

Signing comments

  • The tilde character (~) is used when signing a comment on a talk page. Your username provides a link to your user page.
More information Description, What you type ...

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

  • The 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.
More information What you type, What it looks like ...
  • You can also use an internal diff link. Unlike the template {{diff}}, this kind of link can even be used in edit summaries.
More information What you type, What it looks like ...
  • If the diff intended to be shown is between an immediately previous revision, the first parameter can be dropped.
More information What you type, What it looks like ...
  • 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).
More information What you type, What it looks like ...
  • The following markup can be used. For example, for the article Beetroot:
More information What you type, What it looks like ...

User edits

More information Description, What you type ...

Coloring and highlighting text

More information What you type, What it looks like ...


Example text

The {{xt}} family of templates can be used to highlight example text. These templates do not work in mainspace—that is, in regular articles—they are intended for use on project pages (such as Wikipedia:Manual of Style), help pages, and user pages.

More information What you type, What you get ...

Show deleted or inserted text

  • When editing regular Wikipedia articles, just make your changes, and do not mark them up in any special way, except when the article itself discusses deleted or inserted content, such as an amendment to a statute:
    • to indicate deleted content, use <del>...</del>
    • to indicate inserted content, use <ins>...</ins>
  • This also applies to changing one's own talk page comments.
More information What you type, What it looks like ...

Strikethrough

The {{Strikethrough}} template marks up a span of text with the <s>...</s> tag. This is usually renderend visually by drawing a horizontal line through it. Outside of articles, it can be used to mark something as no longer accurate or relevant without removing it from view. Do not use it, however, to indicate document edits. For that, use the <del>...</del> tag instead. See § Show deleted or inserted text for details.

More information What you type, What you get ...

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!

More information What you type, What it looks like ...

Nowiki

<nowiki>...</nowiki> (wiki markup contained between these two tags is displayed as normal text)
<nowiki /> (wiki markup that is interrupted by this tag is displayed as normal text, as detailed in examples below)

These two kinds of nowiki operate in different ways, but both neutralize the rendering of wiki markup as shown in the examples below. For example, the characters that have wiki markup meaning at the beginning of a line (*, #, ; and :) can be rendered in normal text. Editors can normalize the font of characters trailing a wikilink, which would otherwise appear in the wikilink font. And newlines added to wikitext for readability can be ignored.

Note to template editors: tag <nowiki> works only on its source page, not the target.

More information Markup, Renders as ...

The rest of the section consists of simple, live examples showing how a single nowiki tag escapes entire linkage structures, beyond [[wikilink]] and {{template}}:

[[ fullpagename | label ]]
{{ pagename | parameter }}
[[ fullpagename | {{ pagename }} ]]
{{ pagename | [[ fullpagename ]] }}
{{ pagename | {{ pagename }} }}

Unless you use the two "balanced" nowiki tags, troubleshooting strip marker errors and template parameter-handling inconsistencies is a risk. Also, a rendering error may arise when two [[...]] square brackets are on the same line, or two {{...}} curly brackets are in the same section, but only when the two have the nowiki markup placed inconsistently.

(These are all live examples.)

More information Markup, Renders as ...

For nested structures, escaping an inner structure escapes its outer structure too.

More information Markup, Renders as ...

For two, first pipes, two nowiki tags are required:

More information Markup, Renders as ...

Displaying template calls

For templates, put nowiki before the first pipe. If a parameter has a wikilink, put it in that, an inmost position.

More information Markup, Renders as ...

Displaying magic words

For input parameters, {{{1}}}, {{{2}}}, just write them out, unless they have a default (which goes behind their pipe): {{<nowiki />{1|default}}} {{{1|default}}}

For a parser function nowiki goes between bracketing-pair characters, or anywhere before the : colon.

More information Markup, Renders as ...

Behavioral switches expect the tag anywhere:

More information Markup, Renders as ...

Displaying tags

Tags do not display; they are just markup. If you want them to, insert <nowiki /> after an < opening angle bracket; it goes only in the very front. Opening tags and closing tags must be treated separately.

More information Markup, Renders as ...

Use template {{tag}} instead of nowiki tags to display parser tags:

Character entities, nowiki cannot escape. To escape HTML or special character entities, replace & with &amp;. For example, &amp;lt; &lt;

To display a nowiki tag, you can (1) use {{tag}}, (2) replace the < left angle bracket with its HTML character entity, or (3) nest nowiki tags in each other:

More information Markup, Renders as ...

Nowiki tags do not otherwise nest, so it is the second and fourth that displays:

More information Markup, Renders as ...

These simply scan from left to right. The paired tags cannot overlap, because the very first pair-match nullifies any intervening tags inside. Unbalanced tags always display.

Nowiki tags do not display table markup, use <pre>...</pre>.

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-like and wiki markup tags are escaped, spaces and line breaks are preserved, but HTML elements are parsed.

More information Markup, Renders as ...

As <pre> is a parser tag, it escapes wikitext and HTML tags. This can be prevented with the use of <includeonly></includeonly> within the <pre>, making it act more like its HTML equivalent:

More information Markup, Renders as ...

Invisible HTML <pre> tags can also be inserted by preceding text with a space character, like:

wiki markup &

Alternatively, consider using {{pre}} template or <syntaxhighlight 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 visible only 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

More information Code, Effect ...

{{NUMBEROFARTICLES}} is the number of pages in the main namespace that 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.

Common templates

More information Images, Cite web ...

Notes

  1. Wikipedia is an encyclopedia that uses wikitext—wikitext is not named after Wikipedia.
  2. The version of LaTeX used is a subset of AMS-LaTeX markup; see Help:Displaying a formula for details.

See also

See the 'Coding wiki markup' section of the Help navigation navbox below for additional links.


Share this article:

This article uses material from the Wikipedia article Wikipedia:Wikicode, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.