Help:HTML in wikitext: Difference between revisions
Tags: Mobile edit Mobile web edit |
Divinations (talk | contribs) m Reverted edits by ~2026-42680-12 (talk) to last version by Shirayuki Tags: Rollback Mobile edit Mobile web edit Advanced mobile edit |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 7: | Line 7: | ||
== Allowed HTML tags and attributes == <!--T:2--> |
== Allowed HTML tags and attributes == <!--T:2--> |
||
</translate> |
</translate> |
||
{| class="wikitable sortable" |
{| class="wikitable sortable" |
||
|+<translate><!--T:104--> Allowed HTML tags and attributes in MediaWiki software</translate> |
|+<translate><!--T:104--> Allowed HTML tags and attributes in MediaWiki software</translate> |
||
| Line 431: | Line 430: | ||
|} |
|} |
||
| ⚫ | |||
<!-- to access the TU string only --> |
|||
=== |
=== Common attributes === <!--T:114--> |
||
<!--T:112--> |
|||
The following attributes are permitted on almost all tags listed in the table above (except <tvar name=1><code>meta</code></tvar> and <tvar name=2><code>link</code></tvar>): |
The following attributes are permitted on almost all tags listed in the table above (except <tvar name=1><code>meta</code></tvar> and <tvar name=2><code>link</code></tvar>): |
||
</translate> |
</translate> |
||
| Line 510: | Line 510: | ||
| |
| |
||
|} |
|} |
||
| ⚫ | |||
| ⚫ | |||
== Use cases == <!--T:76--> |
== Use cases == <!--T:76--> |
||
| Line 523: | Line 523: | ||
=== CSS formatting === <!--T:80--> |
=== CSS formatting === <!--T:80--> |
||
</translate> |
|||
| ⚫ | |||
<translate nowrap> |
|||
| ⚫ | |||
<!--T:82--> |
<!--T:82--> |
||
Using HTML tag instead of wikitext equivalent allows you to add a <tvar name=1><code>style</code></tvar> attribute to define a custom display through [[:en:CSS|CSS language]]. |
Using HTML tag instead of wikitext equivalent allows you to add a <tvar name=1><code>style</code></tvar> attribute to define a custom display through [[:en:CSS|CSS language]]. |
||
| ⚫ | |||
<translate nowrap> |
|||
| ⚫ | |||
</translate> |
</translate> |
||
<translate><!--T:84--> Thanks to [[<tvar name=1>Special:MyLanguage/Help:TemplateStyles</tvar>|TemplateStyles]], you may add a custom stylesheet to the document.</translate> |
<translate><!--T:84--> Thanks to [[<tvar name=1>Special:MyLanguage/Help:TemplateStyles</tvar>|TemplateStyles]], you may add a custom stylesheet to the document.</translate> |
||
| Line 549: | Line 547: | ||
<translate nowrap> |
<translate nowrap> |
||
=== <tvar name=1> |
=== <tvar name=1>pre</tvar> tag === <!--T:89--> |
||
<!--T:90--> |
<!--T:90--> |
||
The content of a <tvar name=1><code>pre</code></tvar> tag is not parsed, as in a <tvar name=2>{{tag|nowiki|open}}</tvar> tag. |
The content of a <tvar name=1><code>pre</code></tvar> tag is not parsed, as in a <tvar name=2>{{tag|nowiki|open}}</tvar> tag. |
||
| ⚫ | |||
<!--T:91--> |
<!--T:91--> |
||
You have to use the equivalent wikitext syntax to allow the content parsing. i.e. start each line with a blank space: |
You have to use the equivalent wikitext syntax to allow the content parsing. i.e. start each line with a blank space: |
||
Latest revision as of 06:30, 2 August 2026
| Note: When you edit this page, you agree to release your contribution under the CC0. See Public Domain Help Pages for more info. |
MediaWiki is able to parse some HTML tags in wikitext. Brackets for other tags are escaped and the tags are displayed instead of being parsed.
Allowed HTML tags and attributes
[edit | edit source]| Tag | Meaning | Allowed attributes | Tag allowed since… | Notes |
|---|---|---|---|---|
<abbr>
|
Abbreviation | Common attributes | 1.16 | |
<b>
|
Bring attention | Common attributes | 1.1 | Wikitext: three single quotes, e.g. Be careful to '''this text'''.
|
<bdi>
|
Bidirectional isolate | Common attributes | 1.20 | |
<bdo>
|
Bidirectional text override | Common attributes | 1.22 | |
<big>
|
Make text bigger | Common attributes | 1.1 | <big> is deprecated in HTML, but not in wikitext (T154067)
|
<blockquote>
|
Block quotation | Common attributes + cite
|
1.1 | |
<br>
|
Line break | Common attributes + clear
|
1.1 | |
<caption>
|
Table caption | Common attributes + align
|
1.1 | |
<cite>
|
Citation, i.e. reference to a cited creative work. | Common attributes | 1.1 | |
<code>
|
Inline computer code | Common attributes | 1.1 | |
<col>
|
Common attributes + span
|
|||
<colgroup>
|
Common attributes + span
|
|||
<data>
|
Data, linked to machine-readable translation through value attribute.
|
Common attributes + value
|
1.21 | |
<dd>
|
Description details for a description term element, inside a description list. | Common attributes | 1.1 | Wikitext: : starting the line, respectively for description list details.
|
<del>
|
Deleted text | Common attributes + cite, datetime
|
1.3 | |
<dfn>
|
Definition. Wrap a term/phrase which is being defined. | Common attributes | 1.17 | |
<div>
|
Content division, to apply CSS formatting to a block. | Common attributes + align
|
1.1 | |
<dl>
|
Description list. | Common attributes | 1.1 | |
<dt>
|
Description term, inside a description list. | Common attributes | 1.1 | Wikitext: ; starting the line, respectively for description list term.
|
<em>
|
Emphasis | Common attributes | 1.1 | |
<h1>
|
Section heading – levels 1 to 6 | Common attributes + align
|
1.1 | Wikitext: pairs of equal signs (see help about formatting).
Note when you edit a section headed by an HTML heading, the edit summary will not be prefilled. |
<hr>
|
Thematic break | Common attributes + width
|
1.1 | Wikitext: 4+ dashes (----) starting a line.
|
<i>
|
Idiomatic text | Common attributes | 1.1 | Wikitext: two single quotes, e.g. ''idiomatic text''.
|
<ins>
|
Added text | Common attributes + cite, datetime
|
1.3 | |
<kbd>
|
Keyboard input | Common attributes | 1.17 | |
<li>
|
List item | Common attributes + type, value
|
1.1 | Wikitext: # or * starting the line, respectively for ordered list and unordered list.
|
<link>
|
External resource link | itemprop, href, title
|
1.27 | Must have itemprop and href attributes set.[1] Excludes most values for rel, including the stylesheet value.
|
<mark>
|
Marked or highlighted text. | Common attributes | 1.21 | |
<meta>
|
Metadata | itemprop, content
|
1.27 | Must have itemprop and content attributes set.[1]
|
<ol>
|
Ordered list | Common attributes + type, start, reversed
|
1.1 | |
<p>
|
Paragraph | Common attributes + align
|
1.1 | Wikitext: text between empty lines. |
<pre>
|
Preformatted text | Common attributes + width
|
1.1 | Content is not parsed, as in a <nowiki> tag.
Wikitext: line starting with a blank space, i.e. |
<q>
|
Inline quotation | Common attributes + cite
|
1.22 | |
<rp>
|
Ruby fallback parenthesis | Common attributes | 1.1 | |
<rt>
|
Ruby text: annotation rendered near the base text. Inside a ruby tag.
|
Common attributes | 1.1 | |
<ruby>
|
Ruby annotation. Encloses rt and rp.
|
Common attributes | 1.1 | |
<s>
|
Strikethrough, for no longer accurate or relevant text. | Common attributes | 1.1 | |
<samp>
|
Sample output, inline ouput text of a computer program. | Common attributes | 1.17 | |
<small>
|
Side comment. | Common attributes | 1.1 | |
<span>
|
Content span, to apply CSS formatting to an inline text. | Common attributes | 1.4 | |
<strong>
|
Strong importance. | Common attributes | 1.1 | |
<sub>
|
Subscript | Common attributes | 1.1 | |
<sup>
|
Superscript | Common attributes | 1.1 | |
<table>
|
Table, for tabular data. | Common attributes + summary, width, border, frame, rules, cellspacing, cellpadding, align, bgcolor
|
1.1 | Wikitext: see help page about tables. |
<td>
|
Table data cell, inside a tr tag.
|
Common attributes + abbr, axis, headers, scope, rowspan, colspan, nowrap, width, height, bgcolor, align, valign
|
1.1 | Wikitext: see help page about tables. |
<th>
|
Table header cell, inside a tr tag
|
Common attributes + abbr, axis, headers, scope, rowspan, colspan, nowrap, width, height, bgcolor, align, valign
|
1.1 | Wikitext: see help page about tables. |
<time>
|
Date/Time | Common attributes + datetime
|
1.21 | |
<tr>
|
Table row, inside a table tag.
|
Common attributes + bgcolor, align, valign
|
1.1 | Wikitext: see help page about tables. |
<u>
|
Unarticulated annotation. | Common attributes | 1.1 | |
<ul>
|
Unordered list. | Common attributes + type
|
1.1 | |
<var>
|
Variable | Common attributes | 1.1 | |
<wbr>
|
Line break opportunity. | Common attributes | 1.22 |
Common attributes
[edit | edit source]The following attributes are permitted on almost all tags listed in the table above (except meta and link):
- HTML
idclassstylelangdirtitletabindex
- WAI-ARIA
aria-describedbyaria-flowtoaria-hiddenaria-labelaria-labelledbyaria-levelaria-ownsrole
- RDFa
aboutpropertyresourcedatatypetypeof
- Microdata
itemiditempropitemrefitemscopeitemtype
Deprecated tags
[edit | edit source]The following tags are parsed by MediaWiki, but they are obsolete in HTML 5. They should be replaced with one of above tags.
You might add a style attribute to reproduce the expected display.
| Tag | Allowed since… | Emits Lint error? | Notes |
|---|---|---|---|
<center>
|
1.1 | Yes | |
<font>
|
1.1 | Yes | |
<rb>
|
1.1 | No | |
<rtc>
|
1.24 | No | |
<strike>
|
1.1 | Yes | |
<tt>
|
1.1 | Yes |
Use cases
[edit | edit source]Anchor
[edit | edit source]To create a linkable anchor, you can use any HTML tag with an id attribute.
E.g. <span id="note2"></span> allows you to create a link to its location on the page using [[#note2|See relevant note]].
CSS formatting
[edit | edit source]With style attribute
[edit | edit source]Using HTML tag instead of wikitext equivalent allows you to add a style attribute to define a custom display through CSS language.
With class and id attributes
[edit | edit source]Thanks to TemplateStyles, you may add a custom stylesheet to the document.
So it is useful to add class or id attributes to the elements you want to customize their display.
Overridden HTML syntax
[edit | edit source]HTML comments
[edit | edit source]Wikitext uses HTML comment syntax for its own comments. These comments are ignored by the parser and are not included in the output HTML — not even as HTML comments.
<!-- This text is a wikitext comment. After saving, it will be kept in wikitext source but will not be displayed, neither rendered in HTML source. -->
pre tag
[edit | edit source]The content of a pre tag is not parsed, as in a <nowiki> tag.
You have to use the equivalent wikitext syntax to allow the content parsing. i.e. start each line with a blank space:
Some preformatted text which can contain wikitext, i.e. ''this idiomatic text'' will be parsed. Other line.
to output:
Some preformatted text which can contain wikitext, i.e. this idiomatic text will be parsed. Other line.
See also
[edit | edit source]- Help:Extension:Linter – Help about Linter extension, which notices HTML issues in pages.
- HTML restriction – Information about MediaWiki's default limitations for HTML content, and extensions that expand its support.
- Manual:$wgRawHtml – Extensions allowing further HTML.