Content deleted Content added
No edit summary |
→Obsolete/deprecated elements: big is not obsolete in Linter |
||
(96 intermediate revisions by 41 users not shown) | |||
Line 1:
{{Short description|Usage of HTML tags with MediaWiki}}
<noinclude>{{pp-semi-indef|small=yes}}</noinclude>
{{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}}▼
The [[MediaWiki]] software, which drives Wikipedia, allows the use of a subset of [[HTML5]] [[HTML element|elements]], or tags and their [[HTML attribute|attributes]], for presentation formatting.{{r|sanitizer}}
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
▲{{Wiki markup}}
▲The MediaWiki software, which drives Wikipedia, allows the use of a subset of [[HTML5]] [[HTML element|elements]], or tags and their [[HTML attribute|attributes]], 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 generally preferred within articles, as they are sometimes simpler for most editors and less intrusive in the editing window; but [[Wikipedia:Manual_of_Style#Keep_markup_simple|Wikipedia's Manual of Style]] recommends their use in certain cases. 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|parser and extension tags]], and so are really wiki markup. HTML in pages can be checked for HTML5 compliance by using [[#Validation|validation]]. Some elements and attributes are supported by MediaWiki and browsers, but have been [[Wikipedia:HTML5|deprecated by HTML5]], and therefore should no longer be used.
== Tutorials ==
This help page gives only an overview of allowed markup. For further assistance and detailed specifications:
* [
* [https://www.w3schools.com/html/default.asp HTML5 Introduction] at w3schools.com
== Attributes ==
Line 32 ⟶ 26:
* <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]]
* <code>style</code>: applies CSS styling to the contents of the element.
* <code>title</code>: advisory information associated with the element.
Line 55 ⟶ 49:
{{markup
|<
|2=This is <span style="color:red;">red</span> text.
}}
Line 133 ⟶ 127:
{{tag|p}} is especially useful in lists, for list items with multiple paragraphs:
{{markup|<
* <p>This is a paragraph.</p><p>This is another paragraph in the same item.</p>
* This is a different item.</
|
* <p>This is a paragraph.</p><p>This is another paragraph in the same item.</p>
Line 143 ⟶ 137:
==== br ====
{{see|
{{tag|br|o
{{markup
|<nowiki>HyperText<br>Markup Language</nowiki>
|HyperText<br
}}
Line 176 ⟶ 170:
==== Comments ====
{{see|
{{tag|!--}} formats the enclosed text as a hidden comment.
Line 199 ⟶ 193:
==== abbr ====
{{tag|abbr}} creates a [[Wikipedia:Tooltips|tooltip]] to define an abbreviation or acronym that is displayed on mouse-over.
{{markup
Line 243 ⟶ 237:
Attributes and values:
* <code>dir</code>
** <code>ltr</code>
** <code>rtl</code>
Line 270 ⟶ 264:
|<cite>HyperText Markup Language</cite>
}}
{{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 [[Cascading Style Sheets|CSS]] through {{MediaWiki source|mediawiki.skinning/elements.
{{markup
|<nowiki>use <code>
|use <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: {{tlx|code}} uses {{xtag|syntaxhighlight}}. See the "See also" section at the template page for additional code-markup templates.
See
==== data ====
Line 346 ⟶ 344:
==== 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 374 ⟶ 372:
{{markup
|<nowiki><pre>HyperText Markup Language</pre></nowiki>
|col2=Renders as<ref name="white bgcolor"/>
|col2style=background-color:#fff
|<pre>
Line 383 ⟶ 382:
===== HTML entities =====
{{tag|pre|o}} parses [[Character encodings in HTML|HTML entities]]. If you want to escape this, replace <code>&</code> with <code>&amp;</code>, or use {{xtag|
{{markup
|<nowiki><pre>&amp;</pre></nowiki>
|col2=Renders as<ref name="white bgcolor"/>
|col2style=background-color:#fff
|<pre>
Line 414:
Templates:
* {{tlx|pre}} wraps text that overflows the page.
==== q ====
Line 424 ⟶ 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
▲{{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
|<
東<rtc><rp>(</rp><rt>とう</rt><rp>)</rp></rtc>
京<rtc><rp>(</rp><rt>きょう</rt><rp>)</rp></rtc>
</ruby></
|<ruby>
東<rtc><rp>(</rp><rt>とう</rt><rp>)</rp></rtc>
京<rtc><rp>(</rp><rt>きょう</rt><rp>)</rp></rtc>
</ruby>
}}
Line 454:
==== 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 461:
}}
Templates: {{tlx|strikethrough}} (for inline content), {{tlx|strikethroughdiv}} (for block content)
==== samp ====
Line 467:
{{markup
|<nowiki>sample output: <samp>
|sample output: <samp>
}}
Line 483:
Templates:
* {{tlx|small}} uses {{tag|
==== strong ====
Line 504:
}}
Templates:{{hlist|
|style=line-height:2.5
|indent=3}}
==== sup ====
Line 545 ⟶ 547:
==== 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=<u>: 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
|
|<u>HyperText Markup Language</u>
}}
Templates: {{tlx|underline}} (which supplies the recommended CSS style)
==== var ====
Line 559 ⟶ 563:
{{markup
|1=<syntaxhighlight lang="wikitext">
*
*<
*
</syntaxhighlight>
|2=
*<var>E</var>=<var>m</var>c<sup>2</sup> (c is a constant not a variable)<br />
Line 574 ⟶ 581:
==== wbr ====
{{see|
{{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 596 ⟶ 603:
{{markup
|<
<dt>Term</dt>
<dd>Definition 1</dd>
<dd>Definition 2</dd>
</dl></
|<dl>
<dt>Term</dt>
Line 611 ⟶ 618:
{{markup
|<
: Definition 1
: Definition 2</
|<dl><!-- this wikimarkup does not render in this template -->
<dt>Term</dt>
Line 627 ⟶ 634:
{{markup
|<
<li>Item 1</li>
<li>Item 2</li>
</ol></
|<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
|<
<li>Item 1</li>
<li>Item 2</li>
</ul></
|<ul>
<li>Item 1</li>
Line 647 ⟶ 654:
Wikimarkup: use <code>*</code> for items in an unordered list and <code>#</code> for ordered lists.
{{markup
|1=<
# Item 2</
|2=<nowiki />
# Item 1
# Item 2
|3=<
* Item 2</
|4=<nowiki />
* Item 1
Line 687 ⟶ 694:
{{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
|<
<tr>
<td>data</td>
<td>data</td>
</tr>
</table></
|2=<table border=1>
<tr>
Line 717 ⟶ 723:
{{markup
|<
<tr>
<th>Header</th>
Line 726 ⟶ 732:
<td>data</td>
</tr>
</table></
|2=<table border="1">
<tr>
Line 747 ⟶ 753:
{{markup
|<
<caption>Caption</caption>
<tr>
Line 753 ⟶ 759:
<td>data</td>
</tr>
</table></
|2=<table border=1>
<caption>Caption</caption>
Line 772 ⟶ 778:
== Obsolete/deprecated elements ==
{{main|Wikipedia:HTML5#Obsolete elements and attributes}}
These elements are now obsolete and either deprecated or removed in HTML5,
=== big ===
{{dc|{{tag|big}} (obsolete)}} was used to render text in a "large" font.
Templates: {{tlx|big}} uses CSS.
=== center ===
{{for|centering tables|Help:Table#Centering tables}}
{{dc|{{tag|center}} (obsolete)}}
Templates: {{tlx|center}} uses CSS.
=== font ===
{{dc|{{tag|font}} (obsolete)}}
Templates: {{tlx|font}} uses CSS.
=== rb ===
{{dc|{{tag|rb}} (obsolete)}}
For replacements, see: [[Help:HTML in wikitext#rp, rt, rtc, ruby]]
=== strike ===
{{dc|{{tag|strike}} (obsolete)}}
=== tt ===
{{dc|{{tag|tt}} (obsolete)}}
Templates: {{tlx|mono}} uses CSS.
Line 802 ⟶ 815:
=== 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 ===
Line 809 ⟶ 822:
== HTML Tidy ==
{{historical |type=section}}
[[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 ==
Line 825 ⟶ 839:
== See also ==
* [[Help:
* [[Wikipedia:HTML5]]
* [[:Category:Wikipedia XHTML tag-replacing templates]]
== References ==
Line 837 ⟶ 852:
== 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
[[Category:Wikipedia editor help]]
|