The MediaWiki software, which drives Wikipedia, allows the use of a subset of HTML 5elements, or tags and their attributes, for presentation formatting.[1] But most HTML can be included by using equivalent wiki markup or templates; these are generally preferred within articles, as they are sometimes simpler for most editors and less intrusive in the editing window; but Wikipedia's Manual of Style recommends their use in certain cases. (See Help:Wikitext for wiki equivalents to HTML tags not otherwise discussed below.) And HTML is useful outside of articles, for example for formatting within templates. For help with Cascading Style Sheet use within Wikipedia see Help:Cascading Style Sheets.
Some tags look like HTML, but are actually MediaWiki parser and extension tags, and so are really wiki markup. HTML in pages can be checked for HTML5 compliance by using validation. Some elements and attributes are supported by MediaWiki and browsers, but have been deprecated by HTML5, and therefore should no longer be used.
HTML attributes provide additional information about an element and are always specified in the start tag. They are formatted as a name/value pair like name="value".
Global attributes apply to all tags. Attributes not listed here are not allowed by MediaWiki[1]:
support specific attributes – these are listed in the appropriate section.
Markup
Renders as
This is <spanstyle="color:red;">redspan> text.
This is red text.
The MediaWiki Sanitizer.php does some cleanup on attributes. A best practice is to use the proper syntax.
Discards attributes not on a whitelist for the given element.
Turns broken or invalid entities into plaintext.
Double-quotes all attribute values.
Attributes without values are given the name as value.
Double attributes are discarded.
Unsafe style attributes are discarded.
Prepends space if there are attributes.
Elements
These HTML elements are supported by the MediaWiki software. This section gives a brief overview of the HTML element, an example, relevant wikimarkup and templates.
tags are headings for the sections with which they are associated. is used for the article title. Headings are styled through CSS and added to the page's table of contents.
Markup
Renders as
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Wikimarkup: surround the text with the appropriate number of equal signs. Headers formatted with wikimarkup add an [edit] link.
Be careful with spacing around comments. Surrounding a comment with blank lines will result in a blank paragraph, perceived as an extra two blank lines:
Markup
Renders as
Content line 1
Content line 2
Content line 1
Content line 2
Formatting
abbr
... creates a tooltip to define an abbreviation or acronym that is displayed on mouse-over.
Templates: {{quote}}; supports pre-formatted attribution and source parameters. For other specialized quotation templates, see Category:Quotation templates.
cite
... contains the title of a work. This is a new definition in HTML5— in the previous XML implementation was used to contain a citation or a reference to other sources. No formatting is applied when this tag is used.
Markup
Renders as
HyperText Markup Language
HyperText Markup Language
... is generally not used directly in Wikipedia articles, and is often misused; see Wikipedia:HTML 5#cite for replacement instructions.
code
... formats a section of computer code. Styled with CSS through mediawiki.skinning/elements.less as a black monospaced typeface with a grey background (#F8F9FA) and border (#EAECF0).
... represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is italic text.
Markup
Renders as
HyperText Markup Language
HyperText Markup Language
Wikimarkup: Use '' to open and close italic text.
Markup
Renders as
''HyperText Markup Language''
HyperText Markup Language
ins
... indicates a range of text that has been added. Styled as underlined text. Used on talk pages to indicate refactored text; see WP:REDACT.
Markup
Renders as
HyperText Markup Language
HyperText Markup Language
kbd
... indicates user input such as keyboard input or voice commands (but nogray background as with the template {{kbd}}).
Markup
Renders as
Press Enter
Press Enter
Templates:
{{kbd}} applies monospace styling, and a light-grey background to distinguish from code () and output ( or {{samp}}).
{{key press}} renders illustrated keys and keystrokes.
mark
... represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. Marked text is formatted with a yellow background by default.
Markup
Renders as
HyperText Markup Language
HyperText Markup Language
HyperText Markup Language
HyperText Markup Language
Support: Not supported by Internet Explorer 8 and below.
pre
...
element represents a block of preformatted text. In MediaWiki, <pre> is actually a parser tag and not HTML, but the function is the same. It also prevents the parsing of templates.
... is used to indicate content that is no longer accurate or relevant and that has been struck from the page. It is not appropriate when indicating document edits; to mark a span of text as having been removed from a document, use .
... indicates sample output from a program or computing system. Examples include: output of a program, script, or Wikipedia template; status displays or audio announcements made by an app or device; file system directory listings and samples from them, such as paths and file names.
Markup
Renders as
sample output: HTML
sample output: HTML
Templates: {{samp}} applies monospace styling, and gives the text in dark grey to distinguish from code () and input ( or {{kbd}}).
{{small}} uses . {{small}} is recommended over since ... has a semantic meaning that is for fine print, whereas {{small}} is purely stylistic.
strong
... formats a span of text with strong importance or unusual emphasis; in most browsers it renders as boldface. This should generally not be used in Wikipedia articles, per WP:Neutral point of view policy. See MOS:BOLD on use of this element and other boldfacing. Most semantic emphasis, including in quoted material, should be rendered with the element.
... represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is underlining; for example, a span of text in Chinese that is a proper name (a Chinese proper name mark), or span of text that is known to be misspelled.
was presentational element of HTML that was originally used to underline text; this usage was deprecated in HTML4 in favor of the CSS style {text-decoration: underline}.[4] In HTML5, the tag reappeared but its meaning was changed significantly: it now "represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation".[4] This facility is intended for example to provide a red wavy line underline to flag spelling errors at input time but which are not to be embedded in any stored file (unlike an emphasis mark, which would be).
Markup
Renders as
HyperText Markup Language
HyperText Markup Language
Templates: {{underline}} (which supplies the recommended CSS style)
... formats text in italics to indicate a variable in a mathematical expression or programming context, or placeholder text that the reader is meant to mentally replace with some other literal value.
Markup
Renders as
*<var>Evar>=<var>mvar>c<sup>2sup> (c is a constant not a variable)
*<code><nowiki>{{nowiki><var>TemplateNamevar>|<var>parametervar>=<var>valuevar><nowiki>}}nowiki>code>*If <var>Avar> then <var>Bvar>
is a word break opportunity; that is, it specifies where it would be OK to add a line-break where a word is too long, or it is perceived that the browser will break a line at the wrong place.
Markup
Renders as
Now is the time to become a power editor, by learning HyperText Markup Language
Now is the time to become a power editor, by learning HyperText Markup Language
Now is the time to become a power editor, by learning HyperText Markup Language
Now is the time to become a power editor, by learning HyperText Markup Language
As the browser window is adjusted narrower, the second example wraps between Hyper and Text.
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.
dl, dt, dd
...
,
...
and
...
are used to create a description list (formerly definition list) with terms and descriptions. Terms are displayed in bold and descriptions are indented. Each term must include one or more descriptions.
Wikimarkup: is created using ; while automatically enclosed in
...
. is created using : for each value. For a single or first value the : can be placed on the same line after ; where subsequent values must be placed on separate lines.
These elements are now obsolete and either deprecated or removed in HTML5, but still supported by browsers.[5] These tags should not be used on Wikipedia. These tags either have an alternate tag or a template that replaces their function with CSS. See Wikipedia:HTML5 § Obsolete elements and attributes for more details on obsolete HTML parts and their replacements.
These elements are not supported, but have equivalent wiki markup. Attempting to use any element not whitelisted by Sanitizer.php will result in the markup showing as plain text.
is used to create forms. The <inputbox> extension tag is used to create a text box with a button.
HTML Tidy
HTML Tidy is an outdated HTML4 library that is slated for removal. Tidy parses the MediaWiki output and cleans it up to increase the likelihood that valid HTML4 is rendered. For example, with Tidy enabled, , , , all rendered as . Tidy is not enabled for MediaWiki interface pages. Tidy was never perfect and has been known to introduce errors.
Exceptions
In some pages in the MediaWiki namespace, typically the short messages like button labels, HTML is not parsed, and tags will be exposed.
The MediaWiki software attempts to fix HTML errors, but it does not catch all of them. Where HTML is used, it is helpful to verify it with the W3C Markup Validation Service.
For a listing of current collaborations, tasks, and news, see the Community portal. For a listing of ongoing discussions and current requests, see the Dashboard.