Help:HTML in wikitext: Difference between revisions

Content deleted Content added
Obsolete elements: Adding link to WP:HTML5; commenting out examples per BEANS
Obsolete/deprecated elements: big is not obsolete in Linter
 
(233 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Usage of HTML tags with MediaWiki}}
{{shortcut|H:HTML|WP:HTML}}
<noinclude>{{pp-semi-indef|small=yes}}</noinclude>
{{Wikipedia how to}}
 
{{Redirect|WP:HTML|general information about the default markup language on Wikipedia|Wikipedia:HTML5}}{{For|wikitext equivalents to HTML tags|Help:Wikitext}}{{Locutions pages header}}
{{Wikipedia how to|H:HTML|WP:HTML}}
 
{{Wiki markup}}
{{HTML}}
 
The [[MediaWiki]] software, which drives Wikipedia, allows the use of a subset of [[HTML5]] [[HTML element|elementelements]]s, or tags and their [[HTML attribute|attributeattributes]]s, for presentation formatting.{{r|sanitizer}} ButHowever, most HTML functionality can be included byreplicated using equivalent [[Help:Wiki markup|wiki markup]] or [[Help:TemplateTemplates|templates]];. theseThese alternatives are ''generally preferred'' within articles, asbecause they are often simpler for most editors, to use and less intrusive in the editing windowinterface. But[[Wikipedia:Manual_of_Style#Keep_markup_simple|Wikipedia's HTMLManual isof usefulStyle]] outsiderecommends ofwhen articles,and forwhere examplethese foralternatives formattingshould withinbe templatesused. For(See help[[Help:Wikitext]] withfor Cascadingwikitext Styleequivalents Sheetto useHTML withintags Wikipedianot seeotherwise [[Help:Cascadingdiscussed Style Sheets]]below.)
 
HTML can also be useful outside articles, such as for formatting within templates. For assistance with using Cascading Style Sheets on Wikipedia, see [[Help:Cascading Style Sheets]].
Some tags look like HTML, but are actually MediaWiki [[Help:HTML in wikitext#Parser and extension tags|parser and extension tags]], and so are really wiki markup. HTML in pages can be checked for HTML5 compliance by using [[Help:HTML_in_wikitext#Validation|validation]].
{{TOC limit|3}}
 
Some tags that resemble HTML are actually MediaWiki [[#Parser and extension tags|parser and extension tags]], and so are actually wiki markup. HTML included in pages can be validated for HTML5 compliance by using [[#Validation|validation]]. Note that some elements and attributes supported by MediaWiki and browsers have been [[Wikipedia:HTML5|deprecated by HTML5]] and should no longer be used.{{TOC limit|3}}
==Tutorials==
 
== Tutorials ==
This help page gives only an overview of allowed markup. For further assistance and detailed specifications:
* [https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Introduction_to_HTML5 HTML5 Introduction] at developer.mozilla.org
* [http://www.w3schools.com/html/html5_intro.asp HTML5 Introduction] at w3schools.com
 
* [https://developer.mozilla.org/en-US/docs/Learn/HTML HTML5 Introduction] at developer.mozilla.org
==Attributes==
* [https://www.w3schools.com/html/default.asp HTML5 Introduction] at w3schools.com
 
== Attributes ==
[[HTML attribute]]s provide additional information about an element and are always specified in the start tag. They are formatted as a name/value pair like <code>name="value"</code>.
 
Global attributes apply to all tags. Attributes not listed here are not allowed by MediaWiki{{r|sanitizer}}:
* <code>class</code>: one or more classifications to which the element belongs. See [[Wikipedia:Catalogue of CSS classes]].
* <code>dir</code>: text direction— "<code>"ltr"</code>" (left-to-right), "<code>"rtl"</code>" (right-to-left) or "<code>"auto"</code>".
* <code>id</code>: unique identifier for the element.
* <code>lang</code>: primary language for the contents of the element per [[BCP 47]]. The MediaWiki software automatically adds the <code>xml:lang</code> attribute whenever <code>lang</code> is defined, but <code>xml:lang</code> will no longer be passed when included as a separate attribute.
* <code>style</code>: applies CSS styling to the contents of the element.
* <code>title</code>: advisory information associated with the element.
Line 44 ⟶ 49:
 
{{markup
|<nowikisyntaxhighlight lang="html">This is <span style="color:red;">red</span> text.</nowikisyntaxhighlight>
|2=This is <span style="color:red;">red</span> text.
}}
 
Line 57 ⟶ 62:
* Prepends space if there are attributes.
 
== Elements ==
These [[HTML element]]s are supported by the MediaWiki software. This section gives a brief overview of the HTML element, an example, relevant wikimarkup and templates.
 
=== Basic ===
 
==== h1, h2, h3, h4, h5, h6 ====
{{see|Help:Section|MOS:HEAD}}
The {{tag|h1}} through {{tag|h6}} tags are headings for the sections with which they are associated. {{tag|h1|o}} is used for the article title. Headings are [[Help:Cascading Style Sheets#Wiki headings|styled through CSS]] and added to the page's [[Help:table of contents|table of contents]].
 
{{markup
Line 82 ⟶ 87:
 
Wikimarkup: surround the text with the appropriate number of equal signs. Headers formatted with wikimarkup add an [edit] link.
<section begin="WIKI_section" />
{{markup
|<nowiki>= Heading 1 =
Line 97 ⟶ 102:
{{fake heading|sub=6|Heading 6}}
}}
<section end="WIKI_section" />
Wiki headers use the following default CSS:
<section begin=HTML_section />
{| class="wikitable"
|-
! Wikimarkup !! [[HTML]] !! Style
|-
| {{nowrap|1=<code>= Heading =</code>}} || {{tag|h1|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.8em; font-family: Georgia,Times,serif; margin-top: 1em; margin-bottom: 0.25em; line-height: 1.3; padding: 0; border-bottom: 1px solid #AAAAAA;</source>
|-
| {{nowrap|1=<code>== Heading ==</code>}} || {{tag|h2|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.5em; font-family: Georgia,Times,serif; margin-top: 1em; margin-bottom: 0.25em; line-height: 1.3; padding: 0; border-bottom: 1px solid #AAAAAA;</source>
|-
| {{nowrap|1=<code>=== Heading ===</code>}} || {{tag|h3|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.17em; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
|-
| {{nowrap|1=<code>==== Heading ====</code>}} || {{tag|h4|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
|-
| {{nowrap|1=<code>===== Heading =====</code>}} || {{tag|h5|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
|-
| {{nowrap|1=<code>====== Heading ======</code>}} || {{tag|h6|o}} || <source lang="css">color: #000000; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
|-
|}
<section end=HTML_section />
Templates: {{tl|fake heading}} for use in documentation
 
Templates: {{tlx|fake heading}} for use in documentation
====p====
 
==== p ====
{{tag|p}} tag places content into a separate paragraph.
 
Line 139 ⟶ 125:
}}
 
{{tag|p}} is especially useful in lists, for list items with multiple paragraphs:
====br====
 
{{see|Wikipedia:Line-break handling|Wikipedia:Don't use line breaks}}
{{markup|<syntaxhighlight lang="tid">
{{tag|br|o}} or {{tag|br|s}} inserts a line break. Both versions of the break are supported by HTML5. {{tag|br|c}} is invalid.
* <p>This is a paragraph.</p><p>This is another paragraph in the same item.</p>
* This is a different item.</syntaxhighlight>
|
* <p>This is a paragraph.</p><p>This is another paragraph in the same item.</p>
* This is a different item.}}
 
Note that the closing tag {{tag|p|c}} is not strictly necessary for MediaWiki installations that output HTML 5 (such as Wikipedia).
 
==== br ====
{{see|Help:Line-break handling#&lt;br&gt;| Wikipedia:Don't use line breaks}}
{{tag|br|o}} inserts a line break. See [[H:BR]] for the other 4 versions that the [[MediaWiki]] software converts to {{tag|br|s}} in the HTML that browsers read.
 
{{markup
Line 149 ⟶ 146:
 
Templates:
* {{tltlx|break}} adds multiple line breaks.
* {{tltlx|crlf2}} adds a true carriage return and line feed.
* {{tltlx|-clear}} adds a break with styling to clear floating elements.
* {{tltlx|plainlist}} creates an unbulleted list.
 
==== hr ====
{{see|WP:LINE}}
{{tag|hr|o}} or {{tag|hr|s}} represents a paragraph-level thematic break and presents as a horizontal rule.
 
{{markup
|<nowiki><hr /></nowiki>
|<hr />
}}
 
Line 170 ⟶ 167:
}}
 
Templates: {{tltlx|hr}}
 
====comment Comments ====
{{see|WPMOS:COMMENT}}
{{tag|!--}} formats the enclosed text as a hidden comment.
 
Line 181 ⟶ 178:
}}
 
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:
===Formatting===
 
{{markup|<nowiki>Content line 1
====abbr====
 
{{tag|abbr}} creates a tooltip to define an abbreviation or acronym that is displayed on mouse-over.
<!-- Comment -->
 
Content line 2</nowiki>|Content line 1
 
<!-- Comment -->
 
Content line 2}}
 
=== Formatting ===
 
==== abbr ====
{{tag|abbr}} creates a [[Wikipedia:Tooltips|tooltip]] to define an abbreviation or acronym that is displayed on mouse-over.
 
{{markup
Line 191 ⟶ 200:
}}
 
Templates: {{tlx|abbr}}
Support: not supported by IE6 or IE7.
 
Templates: {{tl|abbr}}; supports Unicode display
 
==== b ====
{{see|MOS:BOLD}}
{{tag|b}} formats text stylistically offset from other text (bold) without conveying extra importance.
Line 211 ⟶ 218:
}}
 
==== bdi ====
 
{{tag|bdi}} isolates the content from the surrounding text-direction settings.
Line 226 ⟶ 233:
Support: Firefox, Chrome
 
==== bdo ====
{{tag|bdo}} specifies the text direction.
 
Attributes and values:
* <code>dir</code> Specifies the text direction.
** <code>ltr</code>
** <code>rtl</code>
Line 239 ⟶ 246:
}}
 
==== blockquote ====
{{see|MOS:QUOTE}}
{{tag|blockquote}} presents text in an offset block.
Line 248 ⟶ 255:
}}
 
Templates: {{tltlx|quote}}; supports pre-formatted attribution and source parameters. For other specialized quotation templates, see [[:Category:Quotation templates]].
 
==== cite ====
{{tag|cite}} contains the title of a work and by default is formatted in italics. This is a new definition in HTML5— in the previous XML implementation {{tag|cite|o}} was used to contain a citation or a reference to other sources. No formatting is applied when this tag is used.
 
{{markup
Line 258 ⟶ 265:
}}
 
{{tag|cite}} is generally not used directly in Wikipedia articles, and is often misused; see [[Wikipedia:HTML 5#cite]] for replacement instructions.
====code====
 
{{tag|code}} formats a section of computer code. Styled with CSS through {{elements.css}} as a Courier monospaced slab serif typeface with border.
==== code ====
{{tag|code}} formats a section of computer code. Styled with [[Cascading Style Sheets|CSS]] through {{MediaWiki source|mediawiki.skinning/elements.less}} as a black [[Monospaced font|monospaced]] typeface with a grey background (#F8F9FA) and border (#EAECF0).
 
{{markup
|<nowiki>use <code>HyperTextthis Markup Languagecode</code></nowiki>
|use <code>HyperTextthis Markup Languagecode</code>
|col2=Renders as<ref name="white bgcolor">For the table cell a white background color was chosen here for a better display of the light gray background.</ref>
|col2style=background-color:#fff;
}}
 
Templates: {{tltlx|code}} uses {{xtag|syntaxhighlight}}. See the "See also" section at the template page for additional code-markup templates.
 
See {{section link||samp}} and {{section link||kbd}} on this page for semantic markup of output and input, respectively.
 
==== data ====
{{tag|data}} formats a machine-readable version of contents.
 
Line 278 ⟶ 291:
Attributes: <code>value</code>
 
==== del ====
{{tag|del}} formats deleted text.
 
Line 286 ⟶ 299:
}}
 
==== dfn ====
{{tag|dfn}} is used for indicating the defining instance of a definitionterm.
 
{{markup
Line 294 ⟶ 307:
}}
 
Templates: {{tltlx|dfn}}
 
==== em ====
{{see|MOS:ITALIC}}
{{tag|em}} represents a span of text with emphatic stress (i.e. semantic emphasis). In most browsers, it renders as italic.
 
{{markup
Line 305 ⟶ 318:
}}
 
Templates: {{tltlx|em}}
 
==== i ====
{{see|MOS:ITALIC}}
{{tag|i}} 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.
Line 322 ⟶ 335:
}}
 
==== ins ====
{{tag|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]].
 
Line 330 ⟶ 343:
}}
 
==== kbd ====
{{tag|kbd}} indicates user input such as keyboard input or voice commands (but ''no'' {{kbd|gray background}} as with the template {{tlx|kbd}}).
 
{{markup
Line 339 ⟶ 352:
 
Templates:
* {{tlx|kbd}} applies monospace styling, and a light-grey background to distinguish from code ({{tag|code|o}}) and output ({{tag|samp|o}} or {{tlx|samp}}).
* {{tl|kbd}} applies gray styling
* {{tltlx|key press}} renders illustrated keys and keystrokes.
 
==== mark ====
{{tag|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.
{{hidden begin}}
It does not highlight leading or trailing whitespace characters. To do so, use [[non-breaking space]]s instead, e.g., using the function {{tl|spaces}}.
{{hidden end}}
 
{{markup
|<nowiki><mark>HyperText Markup Language</mark></nowiki>
|<mark>HyperText Markup Language</mark>
|<nowiki><mark style="background:lightblue;">HyperText Markup Language</mark></nowiki>
|4=<mark style="background:lightblue;">HyperText Markup Language</mark>
}}
 
Support: Not supported by Internet Explorer 8 and below.
 
==== pre ====
{{tag|pre}} element represents a block of preformatted text. In MediaWiki, {{xtag|pre}} is actually a parser tag and not HTML, but the function is the same. It also prevents the parsing of templates.
 
{{markup
|<nowiki><pre>HyperText Markup Language</pre></nowiki>
|col2=Renders as<ref name="white bgcolor"/>
|<pre>HyperText Markup Language</pre>
|col2style=background-color:#fff
 
|<pre>
HyperText Markup Language
</pre>
}}
 
'''===== HTML entities''' =====
 
{{xtagtag|pre|o}} parses [[Character encodings in HTML|HTML entities]]. If you want to escape this, replace <code>&</code> with <code>&amp;amp;</code>, or use {{xtag|syntaxhighlight|params = lang="text"}} instead.
 
{{markup
|<nowiki><pre>&amp;amp;</pre></nowiki>
|col2=Renders as<ref name="white bgcolor"/>
|<pre>&amp;</pre>
|col2style=background-color:#fff
 
|<pre>
&amp;
</pre>
|<nowiki><pre>&amp;lt;</pre></nowiki>
 
|<pre>&lt;</pre>
 
|<pre>
&lt;
</pre>
|<nowiki><pre>&amp;amp;amp;</pre></nowiki>
 
|<pre>&amp;amp;</pre>
 
|<pre>
&amp;amp;
</pre>
|<nowiki><pre>&amp;amp;lt;</pre></nowiki>
 
|<pre>&amp;lt;</pre>
 
|<pre>
&amp;lt;
</pre>
}}
 
Templates:
* {{tltlx|pre}} wraps text that overflows the page.
* {{tl|pre2}} wraps or uses scrollbox.
 
==== q ====
{{tag|q}} is used to mark a short quotation. There has been very little implementation of this element in Wikipedia yet.
 
{{markup
Line 392 ⟶ 423:
}}
 
[[MOS:QUOTATIONS]] says Wikipedia should instead use "", {{tl|quote}}, or <nowiki><blockquote></nowiki>.
====rp, rt, ruby====
 
==== rp, rt, rtc, ruby ====
 
{{see|Ruby character}}
 
{{tag|ruby}} marks spans of phrasing content with ruby annotations.
* {{tag|rtc}} marks a ruby text container for ruby text components in a ruby annotation
 
* {{tag|rt}} marks the ruby text component of a ruby annotation; the ruby text shows in a reduced size over top of the normal characters.
* {{tag|rp}} is used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don't support ruby annotations.
 
{{tag|rp}} is used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don’t support ruby annotations.
 
Browsers that do not support ruby characters will show the ruby text in normal size, enclosed in parentheses and after the normal content.
 
{{markup
|<nowikisyntaxhighlight lang="html"><ruby>
<rtc><rp>(</rp><rt>とう</rt><rp>)</rp></rtc>
<rtc><rp>(</rp><rt>きょう</rt><rp>)</rp></rtc>
</ruby></nowikisyntaxhighlight>
|<ruby>
<rtc><rp>(</rp><rt>とう</rt><rp>)</rp></rtc>
<rtc><rp>(</rp><rt>きょう</rt><rp>)</rp></rtc>
</ruby>
}}
 
Templates:
* {{tltlx|ruby}}
* {{tltlx|ruby-ja}} for Japanese
* {{tltlx|Ruby-zh-p}} for Chinese pinyin
* {{tltlx|Ruby-zh-b}} for Chinese bopomofo
 
==== s ====
{{tag|s}} is used to indicate inline 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 {{tag|del|o}}.
 
{{markup
Line 429 ⟶ 461:
}}
 
Templates: {{tltlx|strikethrough}} (for inline content), {{tlx|strikethroughdiv}} (for block content)
 
==== samp ====
{{tag|samp}} 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
|<nowiki>sample output: <samp>HyperText Markup LanguageHTML</samp></nowiki>
|sample output: <samp>HyperText Markup LanguageHTML</samp>
}}
 
Templates: {{tltlx|samp}} applies graymonospace styling, and gives the text in dark grey to distinguish from code ({{tag|code|o}}) and input ({{tag|kbd|o}} or {{tlx|kbd}}).
 
==== small ====
{{see|WP:FONTSIZE}}
{{tag|small}} format small text.
Line 451 ⟶ 483:
 
Templates:
* {{tltlx|small}} uses {{tag|smallspan|o|params=style="font-size:85%;"}}. {{tltlx|small}} is recommended over {{tag|small|o}} since not{{tag|small}} allhas browsersa rendersemantic meaning that is for [[fine print]], whereas {{tlx|small}} textis thepurely samestylistic.
 
==== strong ====
{{tag|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 {{tag|em|o}} element.
{{tag|strong}} formats a span of text with strong importance.
 
{{markup
Line 461 ⟶ 493:
}}
 
Templates: {{tltlx|strong}}
 
==== sub ====
{{see|WP:SUBSCRIPT}}
{{tag|sub}} formats a span of text as a subscript.
Line 472 ⟶ 504:
}}
 
Templates:{{hlist|
*| {{tltlx|sub}} ({{sub|subscript}} text)
*| {{tltlx|subsub}} ({{subsub|subscript subscript}} text)
*| {{tltlx|ssub}} ({{ssub|subscript, small}} text)
*| {{tltlx|sup}} {{nbsp}}({{sup|superscript}} text)
*| {{tltlx|su}} ({{su|p=superscript|b=subscript}} text)
*| {{tltlx|sup sub}} (text{{sup sub|sup|sub}})
*| {{tltlx|e}} (1.23{{e|4}})
|style=line-height:2.5
|indent=3}}
 
==== sup ====
{{see|WP:SUPSCRIPT}}
{{tag|sup}} formats a span of text as a superscript.
Line 491 ⟶ 525:
 
Templates:
* {{tltlx|sub}} ({{sub|subscript}} text)
* {{tltlx|subsub}} ({{subsub|subscript subscript}} text)
* {{tltlx|ssub}} ({{ssub|subscript, small}} text)
* {{tltlx|sup}} ({{sup|superscript}} text)
* {{tltlx|su}} ({{su|p=superscript|b=subscript}} text)
* {{tltlx|sup sub}} (text{{sup sub|sup|sub}})
* {{tltlx|e}} (1.23{{e|4}})
 
==== time ====
{{tag|time}} defines either a time (24 hour clock), or a date in the Gregorian calendar, optionally with a time and a time-zone offset.
 
Line 511 ⟶ 545:
Support: Not supported by Internet Explorer 8 and below.
 
==== u ====
{{see|MOS:BADEMPHASIS|MOS:QUOTE}}
{{tag|u}} 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.
 
{{tag|u|o}} was [[HTML element#Presentational markup|presentational element of HTML]] that was originally used to underline text; this usage was [[deprecated]] in HTML4 in favor of the [[CSS]] style <code>{text-decoration: underline}</code>.<ref name=mozilla>{{cite web |url=https://developer.mozilla.org/en-US/docs/Web/HTML/Element/u |title=&lt;u&gt;: The Unarticulated Annotation (Underline) element | date = 1 August 2020 |access-date= 9 October 2020 | website= mozilla.org}}</ref> 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".<ref name=mozilla /> 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
|<nowiki><u>HyperText Markup Language</u></nowiki>
|<u>HyperText Markup Language</u>
}}
 
Templates: {{tltlx|underline}} (which supplies the recommended CSS style)
 
==== var ====
{{see|MOS:ITALIC}}
{{tag|var}} 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
|1=<syntaxhighlight lang="wikitext">
|<nowiki><var>HyperText Markup Language</var></nowiki>
*<var>E</var>=<var>m</var>c<sup>2</sup> (c is a constant not a variable)
|<var>HyperText Markup Language</var>
*<code><nowiki>{{</nowiki><var>TemplateName</var>|<var>parameter</var>=<var>value</var><nowiki>}}</nowiki></code>
*If <var>A</var> then <var>B</var>
 
</syntaxhighlight>
 
|2=
*<var>E</var>=<var>m</var>c<sup>2</sup> (c is a constant not a variable)<br />
*<code><nowiki>{{</nowiki><var>TemplateName</var>{{!}}<var>parameter</var>=<var>value</var><nowiki>}}</nowiki></code><br />
*If <var>A</var> then <var>B</var>
}}
 
Templates:
* {{tltlx|var}}
* {{tltlx|varserif}} formatted in italic serif to differentiate characters
 
==== wbr ====
{{see| WikipediaHelp:Line-break handling#&lt;wbr&gt; and soft hyphens}}
{{tag|wbr|o}} 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.
 
Line 544 ⟶ 589:
 
|<nowiki>Now is the time to become a power editor, by learning Hyper<wbr>Text Markup Language</nowiki>
|Now is the time to become a power editor, by learning Hyper<wbr />Text Markup Language
}}
 
As the browser window is adjusted narrower, the second example wraps between ''Hyper'' and ''Text''.
 
=== Lists ===
{{see|Help:List|MOS:LIST}}
 
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 ====
{{tag|dl}}, {{tag|dt}} and {{tag|dd}} 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 <em>must</em> include one or more descriptions.
 
{{markup
|<nowikisyntaxhighlight lang="html"><dl>
<dt>Term</dt>
<dd>Definition 1</dd>
<dd>Definition 2</dd>
</dl></syntaxhighlight>
<dd>Definition 3</dd>
<dd>Definition 4</dd>
</dl></nowiki>
|<dl>
<dt>Term</dt>
<dd>Definition 1</dd>
<dd>Definition 2</dd>
<dd>Definition 3</dd>
<dd>Definition 4</dd>
</dl>
}}
Line 577 ⟶ 618:
 
{{markup
|<nowikisyntaxhighlight lang="wikitext">; Term
: Definition 1
: Definition 2</syntaxhighlight>
: Definition 3
: Definition 4</nowiki>
|<dl><!-- this wikimarkup does not render in this template -->
<dt>Term</dt>
<dd>Definition 1</dd>
<dd>Definition 2</dd>
<dd>Definition 3</dd>
<dd>Definition 4</dd>
</dl>
}}
 
Templates: {{tltlx|defn}}
 
==== ol, ul, li ====
{{tag|ol}} represents an ordered list; {{tag|ul}} represents an unordered list; {{tag|li}} represents a list item within either type of list.
 
{{markup
|<nowikisyntaxhighlight lang="html"><ol>
<li>Item 1</li>
<li>Item 2</li>
</ol></syntaxhighlight>
<li>Item 3</li>
<li>Item 4</li>
</ol></nowiki>
|<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ol>
|<nowikisyntaxhighlight lang="html"><ul>
<li>Item 1</li>
<li>Item 2</li>
</ul></syntaxhighlight>
<li>Item 3</li>
<li>Item 4</li>
</ul></nowiki>
|<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
}}
Line 625 ⟶ 654:
Wikimarkup: use <code>*</code> for items in an unordered list and <code>#</code> for ordered lists.
{{markup
|1=<nowikisyntaxhighlight lang="wikitext"># Item 1
# Item 2</syntaxhighlight>
# Item 3
# Item 4</nowiki>
|2=<nowiki />
# Item 1
# Item 2
|3=<syntaxhighlight lang="wikitext">* Item 1
# Item 3
#* Item 42</syntaxhighlight>
|3=<nowiki>* Item 1
* Item 2
* Item 3
* Item 4</nowiki>
|4=<nowiki />
* Item 1
* Item 2
* Item 3
* Item 4
}}
 
Templates: for a variety of specialized uses, see [[:Category:List formatting and function templates]].
 
=== Containers ===
 
==== div ====
{{see|Span and div}}
{{tag|div}} is a generic container for flow content that displays as a block element.
Line 658 ⟶ 679:
}}
 
==== span ====
{{see|Span and div}}
{{tag|span}} is a container for flow content that displays as an inline element.
Line 664 ⟶ 685:
{{markup
|<nowiki>HyperText <span>Markup</span> Language</nowiki>
|HyperText <span>Markup</span> Language
}}
 
=== Tables ===
{{see|Help:Table|MOS:TABLES}}
 
==== table, td, tr ====
{{tag|table}} defines a table.
 
* {{tag|tr}} defines a table row.
* {{tag|td}} defines a data cell with contents that may include text, links, images, lists, forms, other tables, etc.
 
{{tag|td}} defines a data cell with contents that may include text, links, images, lists, forms, other tables, etc.
 
{{markup
|<nowikisyntaxhighlight lang="html"><table border=1>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table></nowikisyntaxhighlight>
|2=<table border=1>
<tr>
Line 695 ⟶ 715:
* {{tag|table|o}}:
*: Allowed but not recommended: <code>border=""</code> and <code>border="1"</code>
*: Allowed but obsolete: <code>border</code> (with a non-empty value different from "1"), <code>align</code>, <code>bgcolor</code>, <code>cellpadding</code>, <code>cellspacing</code>, <code>frame</code>, <code>rules</code>, <code>summary</code>, <code>width</code><ref name="w3c_obsolete" />
* {{tag|td|o}}: <code>colspan</code>, <code>headers</code>, <code>rowspan</code>
*: Allowed but obsolete: <code>abbr</code>, <code>align</code>, <code>axis</code>, <code>bgcolor</code>, <code>scope</code>, <code>height</code>, <code>nowrap</code>, <code>valign</code>, <code>width</code><ref name="w3c_obsolete" />
 
==== th ====
{{tag|th}} defines a table header; styled as centered and bold.
 
{{markup
|<nowikisyntaxhighlight lang="html"><table border="1">
<tr>
<th>Header</th>
Line 712 ⟶ 732:
<td>data</td>
</tr>
</table></nowikisyntaxhighlight>
|2=<table border="1">
<tr>
Line 727 ⟶ 747:
Attributes:
* {{tag|th|o}}: <code>colspan</code>, <code>headers</code>, <code>rowspan</code>, <code>scope</code>
*: Allowed but obsolete: <code>abbr</code>, <code>align</code>, <code>axis</code>, <code>bgcolor</code>, <code>scope</code>, <code>height</code>, <code>nowrap</code>, <code>valign</code>, <code>width</code><ref name="w3c_obsolete" />
 
==== caption ====
{{tag|caption}} adds a caption to a table.
 
{{markup
|<nowikisyntaxhighlight lang="html"><table border=1>
<caption>Caption</caption>
<tr>
Line 739 ⟶ 759:
<td>data</td>
</tr>
</table></nowikisyntaxhighlight>
|2=<table border=1>
<caption>Caption</caption>
Line 751 ⟶ 771:
Attributes:
* {{tag|caption|o}}:
*: Allowed but obsolete: <code>align</code><ref name="w3c_obsolete" />
 
==== thead, tfoot, tbody ====
{{tag|thead|o}}, {{tag|tfoot|o}} and {{tag|tbody|o}} are not supported, but are automatically generated when the page is rendered.
 
== Obsolete/deprecated elements ==
{{main|Wikipedia:HTML5#Obsolete elements and attributes}}
These elements are now obsolete in HTML5, but still supported by browsers.<ref name=w3c_obsolete /> These tags either have an alternate tag or a template that replaces their function with CSS. See [[Wikipedia:HTML5]] for more details on obsolete HTML parts and their replacements.
These elements are now obsolete and either deprecated or removed in HTML5, although they are still supported by browsers.<ref name="w3c_obsolete" /> '''Their use should be avoided on Wikipedia.''' These tags either have an alternate tag or a template that replaces their function with CSS; except for {{tag|big}}, the tags are being replaced by editors on pages throughout Wikipedia (see [[Wikipedia:Linter]] for more details). See {{slink|Wikipedia:HTML5#Obsolete elements and attributes}} for more details on obsolete HTML parts and their replacements.
 
=== big ===
{{dc|{{tag|big}} (obsolete)}} formatswas used to render text in a larger"large" font size.
<!--
{{markup
|<nowiki><big>HyperText Markup Language</big></nowiki>
|<big>HyperText Markup Language</big>
}}
-->
 
Templates: {{tltlx|big}} uses CSS.
 
=== center ===
{{for|centering tables|Help:Table#Centering tables}}
{{dc|{{tag|center}} (obsolete)}} iswas used to center text elements.
<!--
{{markup
|<nowiki><center>HyperText Markup Language</center></nowiki>
|<center>HyperText Markup Language</center>
}}
-->
 
Templates: {{tltlx|center}} uses CSS.
 
=== font ===
{{dc|{{tag|font}} (obsolete)}} iswas used to set the font size, font face and color of text.
<!--
{{markup
|<source lang="html" inline><font size="3" face="verdana" color="green">HyperText Markup Language</font></source>
|2=<font size="3" face="verdana" color="green">HyperText Markup Language</font>
}}
-->
 
Templates: {{tltlx|font}} uses CSS.
 
=== rb ===
{{dc|{{tag|rb}} (obsolete)}} Usedwas used to mark base text in a ruby annotation.
 
For replacements, see: [[Help:HTML in wikitext#rp, rt, rtc, ruby]]
===strike===
{{dc|{{tag|strike}} (obsolete)}} formats strike-through characters; use {{tag|s|o}} instead.
<!--
{{markup
|<nowiki><strike>HyperText Markup Language</strike></nowiki>
|<strike>HyperText Markup Language</strike>
}}
-->
 
===tt strike ===
{{dc|{{tag|ttstrike}} (obsolete)}} formatsformatted text in a fixedstrike-widththrough font.characters; Useuse {{tag|code|o}}, {{tag|kbd|os}} or {{tag|samp|odel}} instead, depending on the context.
 
<!--
=== tt ===
{{markup
{{dc|{{tag|tt}} (obsolete)}} formatted text in a fixed-width font. Use {{tag|code|o}}, {{tag|kbd|o}}, {{tag|var|o}}, or {{tag|samp|o}} instead, depending on the context.
|<nowiki><tt>HyperText Markup Language</tt></nowiki>
|<tt>HyperText Markup Language</tt>
}}
-->
 
Templates: {{tltlx|mono}} uses CSS.
 
== Unsupported elements ==
 
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.
 
=== a ===
{{details|Help:Wiki markup#Links and URLs}}
{{tag|a|o}} is used to create links. Use the <code><nowiki>[[ ]]</nowiki></code> wikimarkup for internal/intrawiki links and [[Help:Interwiki linking|interwiki links]], and <code><nowiki>[ ]</nowiki></code> for external links.
 
=== input ===
{{details|mw:Extension:InputBox}}
{{tag|input|o}} is used to create [[Form (HTML)|forms]]. The {{xtag|inputbox}} extension tag is used to create a text box with a button.
 
== HTML Tidy ==
{{historical |type=section}}
[[HTML Tidy]] is enabled for the English Wikipedia. Tidy parses the MediaWiki output and cleans it up to ensure that valid HTML is rendered. For example, {{tag|br|o}}, {{tag|br|c}}, {{tag|br/|o}}, {{tag|br.|o}} will all render as {{tag|br|s}}. Tidy is not enabled for [[Help:MediaWiki namespace|MediaWiki interface pages]]. Tidy is not perfect, and has been known to introduce errors.
[[HTML Tidy]] is an outdated HTML4 library{{vague|upstream is now HTML5}} that is [[:mw:Parsing/Replacing Tidy|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, {{tag|br|o}}, {{tag|br|c}}, {{tag|br/|o}}, {{tag|br.|o}} all rendered as {{tag|br|s}}. Tidy is not enabled for [[Help:MediaWiki namespace|MediaWiki interface pages]]. Tidy was never perfect and has been known to introduce errors.
 
== Exceptions ==
In some pages in the [[Help:MediaWiki namespace|MediaWiki namespace]], typically the short messages like button labels, HTML is not parsed, and tags will be exposed.
 
User and sitewide [[CSS]] and [[JavascriptJavaScript]] pages are interpreted as if inside a {{tag|pre|o}} block. See [[Help:User style]].
 
== Validation ==
{{mainMain|Help:Markup validation}}
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]].
 
== Parser and extension tags ==
{{shortcut|Help:Extension tag|Help:Parser tag}}
{{#section:Template:Xtag/doc|xtag}}
 
== See also ==
* [[Help:Wiki markupWikitext]]
* [[Wikipedia:HTML5]]
* [[:Category:Wikipedia XHTML tag-replacing templates]]
 
== References ==
{{reflist|refs=
<ref name="w3c_obsolete">{{cite web |title=HTML5: A vocabulary and associated APIs for HTML and XHTML: Obsolete Features |work=W3C |date=31 July 2014 |url=http://www.w3.org/TR/html5/obsolete.html}}</ref>
<ref name="sanitizer">Allowable elements and attributes are defined in the {{sanitizer.php}} module.</ref>
<ref name="html5microdata">{{cite web |title=The microdata model |work=HTML Living Standard |url=http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-microdata-model}}</ref>
}}
 
== External links ==
* HTML 4.01 specification: [http://www.w3.org/TR/html401/index/elements.html elements] | [http://www.w3.org/TR/html401/index/attributes.html attributes]
* HTML 5.2 specification: [https://www.w3.org/TR/html5/fullindex.html#index-elements elements] | [https://www.w3.org/TR/html5/fullindex.html#attributes-table attributes]
 
{{Wikipedia directories}}
{{Wikipedia editor navigation}}
 
{{Help navigation}}
{{Wikipedia technical help|collapsed}}
[[Category:Wikipedia editor help]]