Help:HTML in wikitext: Difference between revisions

Content deleted Content added
Obsolete elements: Adding link to WP:HTML5; commenting out examples per BEANS
m Synatx upd, remove redirect
Line 3:
{{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}} But most HTML can be included by using equivalent [[Help:Wiki markup|wiki markup]] or [[Help:Template|templates]]; these are ''preferred'' within articles, as they are simpler for most editors, and less intrusive in the editing window. But 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 [[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]].
The MediaWiki software, which drives Wikipedia, allows the use of a subset of [[HTML5]] [[HTML element|element]]s, or tags and their [[HTML attribute|attribute]]s, for presentation formatting.{{r|sanitizer}} But most HTML can be included by using equivalent [[Help:Wiki markup|wiki markup]] or [[Help:Template|templates]]; these are ''preferred'' within articles, as they are simpler for most editors, and less intrusive in the editing window. But 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 [[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}}
 
== 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
 
== 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>.
 
Line 57 ⟶ 56:
* 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 styled through CSS and added to the page's [[Help:table of contents|table of contents]].
Line 82 ⟶ 81:
 
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 ⟶ 96:
{{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}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
| {{nowrap|1=<code>== Heading ==</code>}} || {{tag|h2|o}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
| {{nowrap|1=<code>=== Heading ===</code>}} || {{tag|h3|o}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
| {{nowrap|1=<code>==== Heading ====</code>}} || {{tag|h4|o}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
| {{nowrap|1=<code>===== Heading =====</code>}} || {{tag|h5|o}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
| {{nowrap|1=<code>====== Heading ======</code>}} || {{tag|h6|o}} ||
<sourcesyntaxhighlight 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>
</syntaxhighlight>
|-
|}
<section end="HTML_section" />
Templates: {{tl|fake heading}} for use in documentation
 
==== p ====
{{tag|p}} tag places content into a separate paragraph.
 
Line 139 ⟶ 156:
}}
 
==== br ====
{{see|Wikipedia:Line-break handling|Wikipedia:Don't use line breaks}}
{{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.
Line 145 ⟶ 162:
{{markup
|<nowiki>HyperText<br>Markup Language</nowiki>
|HyperText<br />Markup Language
}}
 
Line 154 ⟶ 171:
* {{tl|plainlist}} creates an unbulleted list.
 
==== hr ====
{{see|WP:LINE}}
{{tag|hr|o}} represents a paragraph-level thematic break and presents as a horizontal rule.
Line 160 ⟶ 177:
{{markup
|<nowiki><hr></nowiki>
|<hr />
}}
 
Line 172 ⟶ 189:
Templates: {{tl|hr}}
 
==== comment ====
{{see|WP:COMMENT}}
{{tag|!--}} formats the enclosed text as a hidden comment.
Line 181 ⟶ 198:
}}
 
=== Formatting ===
 
==== abbr ====
{{tag|abbr}} creates a tooltip to define an abbreviation or acronym that is displayed on mouse-over.
 
Line 195 ⟶ 212:
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 ⟶ 228:
}}
 
==== bdi ====
 
{{tag|bdi}} isolates the content from the surrounding text-direction settings.
Line 226 ⟶ 243:
Support: Firefox, Chrome
 
==== bdo ====
{{tag|bdo}} specifies the text direction.
 
Line 239 ⟶ 256:
}}
 
==== blockquote ====
{{see|MOS:QUOTE}}
{{tag|blockquote}} presents text in an offset block.
Line 250 ⟶ 267:
Templates: {{tl|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.
 
Line 258 ⟶ 275:
}}
 
==== code ====
{{tag|code}} formats a section of computer code. Styled with CSS through {{elements.css}} as a Courier monospaced slab serif typeface with border.
 
Line 268 ⟶ 285:
Templates: {{tl|code}} uses {{xtag|syntaxhighlight}}.
 
==== data ====
{{tag|data}} formats a machine-readable version of contents.
 
Line 278 ⟶ 295:
Attributes: <code>value</code>
 
==== del ====
{{tag|del}} formats deleted text.
 
Line 286 ⟶ 303:
}}
 
==== dfn ====
{{tag|dfn}} is used for indicating a definition.
 
Line 296 ⟶ 313:
Templates: {{tl|dfn}}
 
==== em ====
{{see|MOS:ITALIC}}
{{tag|em}} represents a span of text with emphatic stress.
Line 307 ⟶ 324:
Templates: {{tl|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 ⟶ 339:
}}
 
==== 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 ⟶ 347:
}}
 
==== kbd ====
{{tag|kbd}} indicates user input such as keyboard input or voice commands.
 
Line 342 ⟶ 359:
* {{tl|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}}
Line 357 ⟶ 374:
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.
 
{{markup
|<nowiki><pre>HyperText Markup Language</pre></nowiki>
 
|<pre>HyperText Markup Language</pre>
 
|<pre>
|<pre>HyperText Markup Language</pre>
</pre>
}}
 
Line 371 ⟶ 392:
{{markup
|<nowiki><pre>&amp;amp;</pre></nowiki>
 
|<pre>&amp;</pre>
 
|<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>
|<pre>&amp;amp;</pre>
</pre>
|<nowiki><pre>&amp;amp;lt;</pre></nowiki>
 
|<pre>&amp;lt;</pre>
 
|<pre>
&amp;lt;
</pre>
}}
 
Line 384 ⟶ 421:
* {{tl|pre2}} wraps or uses scrollbox.
 
==== q ====
{{tag|q}} is used to mark a short quotation.
 
Line 392 ⟶ 429:
}}
 
==== rp, rt, ruby ====
 
{{see|Ruby character}}
Line 421 ⟶ 458:
* {{tl|Ruby-zh-b}} for Chinese bopomofo
 
==== s ====
{{tag|s}} 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 {{tag|del|o}}.
 
Line 431 ⟶ 468:
Templates: {{tl|strikethrough}}
 
==== samp ====
{{tag|samp}} indicates sample output from a program or computing system.
 
Line 441 ⟶ 478:
Templates: {{tl|samp}} applies gray styling
 
==== small ====
{{see|WP:FONTSIZE}}
{{tag|small}} format small text.
Line 453 ⟶ 490:
* {{tl|small}} uses {{tag|small|o|params=style="font-size:85%;"}}. {{tl|small}} is recommended over {{tag|small|o}} since not all browsers render small text the same.
 
==== strong ====
{{tag|strong}} formats a span of text with strong importance.
 
Line 463 ⟶ 500:
Templates: {{tl|strong}}
 
==== sub ====
{{see|WP:SUBSCRIPT}}
{{tag|sub}} formats a span of text as a subscript.
Line 481 ⟶ 518:
* {{tl|e}} (1.23{{e|4}})
 
==== sup ====
{{see|WP:SUPSCRIPT}}
{{tag|sup}} formats a span of text as a superscript.
Line 499 ⟶ 536:
* {{tl|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 ⟶ 548:
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.
Line 522 ⟶ 559:
Templates: {{tl|underline}}
 
==== 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.
Line 535 ⟶ 572:
* {{tl|varserif}} formatted in italic serif to differentiate characters
 
==== wbr ====
{{see| Wikipedia:Line-break handling}}
{{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 ⟶ 581:
 
|<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.
 
Line 593 ⟶ 630:
Templates: {{tl|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.
 
Line 647 ⟶ 684:
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 ⟶ 695:
}}
 
==== span ====
{{see|Span and div}}
{{tag|span}} is a container for flow content that displays as an inline element.
Line 664 ⟶ 701:
{{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.
 
Line 695 ⟶ 732:
* {{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.
 
Line 727 ⟶ 764:
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.
 
Line 751 ⟶ 788:
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 elements ==
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.
 
=== big ===
{{dc|{{tag|big}} (obsolete)}} formats text in a larger font size.
<!--
{{markup
|<nowiki><big>HyperText Markup Language</big></nowiki>
|<big>HyperText Markup Language</big>
}}
-->
 
Templates: {{tl|big}} uses CSS.
 
=== center ===
{{for|centering tables|Help:Table#Centering tables}}
{{dc|{{tag|center}} (obsolete)}} is used to center text elements.
<!--
{{markup
|<nowiki><center>HyperText Markup Language</center></nowiki>
|<center>HyperText Markup Language</center>
}}
-->
 
Templates: {{tl|center}} uses CSS.
 
=== font ===
{{dc|{{tag|font}} (obsolete)}} is 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: {{tl|font}} uses CSS.
 
=== rb ===
{{dc|{{tag|rb}} (obsolete)}} Used to mark base text in a ruby annotation
 
=== 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 ===
{{dc|{{tag|tt}} (obsolete)}} formats text in a fixed-width font. Use {{tag|code|o}}, {{tag|kbd|o}} or {{tag|samp|o}} instead.
<!--
{{markup
|<nowiki><tt>HyperText Markup Language</tt></nowiki>
|<tt>HyperText Markup Language</tt>
}}
-->
 
Templates: {{tl|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 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 ==
[[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.
 
== 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 markup]]
 
== 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]