Jump to content

Help:HTML in wikitext: Difference between revisions

From mediawiki.org
Content deleted Content added
Tc14Hd (talk | contribs)
m Removed empty line
m restore translation units :(
Line 38: Line 38:
| <translate><!--T:103--> Make text bigger</translate>
| <translate><!--T:103--> Make text bigger</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:105--> {{tag|big|open}} is deprecated in HTML, but not in wikitext ([[<tvar name=1>phab:T154067</tvar>|T154067]]).</translate>
| <translate><!--T:105--> <tvar name=2>{{tag|big|open}}</tvar> is deprecated in HTML, but not in wikitext ([[<tvar name=1>phab:T154067</tvar>|T154067]])</translate>
|-
|-
|scope="row"| {{tag|blockquote|open}}
|scope="row"| {{tag|blockquote|open}}
Line 56: Line 56:
|-
|-
|scope="row"| {{tag|cite|open}}
|scope="row"| {{tag|cite|open}}
| <translate><!--T:15--> Citation, i.e. reference to a cited creative work</translate>
| <translate><!--T:15--> Citation, i.e. reference to a cited creative work.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
Line 66: Line 66:
|-
|-
|scope="row"| {{tag|data|open}}
|scope="row"| {{tag|data|open}}
| <translate><!--T:17--> Data, linked to machine-readable translation through <code>value</code> attribute</translate>
| <translate><!--T:17--> Data, linked to machine-readable translation through <code>value</code> attribute.</translate>
| data-sort-value="21" | 1.21
| data-sort-value="21" | 1.21
|
|
|-
|-
|scope="row"| {{tag|dd|open}}
|scope="row"| {{tag|dd|open}}
| <translate><!--T:18--> Description details for a description term element, inside a description list</translate>
| <translate><!--T:18--> Description details for a description term element, inside a description list.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:101--> Wikitext: <tvar name=1><code>:</code></tvar> starting the line, respectively for description list details.</translate>
| <translate><!--T:101--> Wikitext: <tvar name=1><code>:</code></tvar> starting the line, respectively for description list details.</translate>
Line 81: Line 81:
|-
|-
|scope="row"| {{tag|dfn|open}}
|scope="row"| {{tag|dfn|open}}
| <translate><!--T:20--> Definition, wrap a term/phrase which is being defined</translate>
| <translate><!--T:20--> Definition. Wrap a term/phrase which is being defined.</translate>
| data-sort-value="17" | 1.17
| data-sort-value="17" | 1.17
|
|
|-
|-
|scope="row"| {{tag|div|open}}
|scope="row"| {{tag|div|open}}
| <translate><!--T:21--> Content division, to apply CSS formatting to a block</translate>
| <translate><!--T:21--> Content division, to apply CSS formatting to a block.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|dl|open}}
|scope="row"| {{tag|dl|open}}
| <translate><!--T:22--> Description list</translate>
| <translate><!--T:22--> Description list.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|dt|open}}
|scope="row"| {{tag|dt|open}}
| <translate><!--T:23--> Description term, inside a description list</translate>
| <translate><!--T:23--> Description term, inside a description list.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:102--> Wikitext: <tvar name=1><code>;</code></tvar> starting the line, respectively for description list term.</translate>
| <translate><!--T:102--> Wikitext: <tvar name=1><code>;</code></tvar> starting the line, respectively for description list term.</translate>
Line 142: Line 142:
|-
|-
|scope="row"| {{tag|mark|open}}
|scope="row"| {{tag|mark|open}}
| <translate><!--T:38--> Marked or highlighted text</translate>
| <translate><!--T:38--> Marked or highlighted text.</translate>
| data-sort-value="21" | 1.21
| data-sort-value="21" | 1.21
|
|
Line 178: Line 178:
|-
|-
|scope="row"| {{tag|rt|open}}
|scope="row"| {{tag|rt|open}}
| <translate><!--T:49--> Ruby text: annotation rendered near the base text, inside a <tvar name=1><code>ruby</code></tvar> tag</translate>
| <translate><!--T:49--> Ruby text: annotation rendered near the base text. Inside a <tvar name=1><code>ruby</code></tvar> tag.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|ruby|open}}
|scope="row"| {{tag|ruby|open}}
| <translate><!--T:50--> Ruby annotation, encloses <tvar name=1><code>rt</code></tvar> and <tvar name=2><code>rp</code></tvar></translate>
| <translate><!--T:50--> Ruby annotation. Encloses <tvar name=1><code>rt</code></tvar> and <tvar name=2><code>rp</code></tvar>.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|s|open}}
|scope="row"| {{tag|s|open}}
| <translate><!--T:51--> Strikethrough, for no longer accurate or relevant text</translate>
| <translate><!--T:51--> Strikethrough, for no longer accurate or relevant text.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|samp|open}}
|scope="row"| {{tag|samp|open}}
| <translate><!--T:52--> Sample output, inline ouput text of a computer program</translate>
| <translate><!--T:52--> Sample output, inline ouput text of a computer program.</translate>
| data-sort-value="17" | 1.17
| data-sort-value="17" | 1.17
|
|
|-
|-
|scope="row"| {{tag|small|open}}
|scope="row"| {{tag|small|open}}
| <translate><!--T:53--> Side comment</translate>
| <translate><!--T:53--> Side comment.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|span|open}}
|scope="row"| {{tag|span|open}}
| <translate><!--T:54--> Content span, to apply CSS formatting to an inline text</translate>
| <translate><!--T:54--> Content span, to apply CSS formatting to an inline text.</translate>
| data-sort-value="10" | 1.4
| data-sort-value="10" | 1.4
|
|
|-
|-
|scope="row"| {{tag|strong|open}}
|scope="row"| {{tag|strong|open}}
| <translate><!--T:55--> Strong importance</translate>
| <translate><!--T:55--> Strong importance.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
Line 223: Line 223:
|-
|-
|scope="row"| {{tag|table|open}}
|scope="row"| {{tag|table|open}}
| <translate><!--T:58--> Table, for tabular data</translate>
| <translate><!--T:58--> Table, for tabular data.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:59--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
| <translate><!--T:59--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
|-
|-
|scope="row"| {{tag|td|open}}
|scope="row"| {{tag|td|open}}
| <translate><!--T:60--> Table data cell, inside a <tvar name=1><code>tr</code></tvar> tag</translate>
| <translate><!--T:60--> Table data cell, inside a <tvar name=1><code>tr</code></tvar> tag.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:61--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
| <translate><!--T:61--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
Line 243: Line 243:
|-
|-
|scope="row"| {{tag|tr|open}}
|scope="row"| {{tag|tr|open}}
| <translate><!--T:65--> Table row, inside a <tvar name=1><code>table</code></tvar> tag</translate>
| <translate><!--T:65--> Table row, inside a <tvar name=1><code>table</code></tvar> tag.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
| <translate><!--T:66--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
| <translate><!--T:66--> Wikitext: [[<tvar name=1>Special:MyLanguage/Help:Tables</tvar>|see help page about tables]].</translate>
|-
|-
|scope="row"| {{tag|u|open}}
|scope="row"| {{tag|u|open}}
| <translate><!--T:67--> Unarticulated annotation</translate>
| <translate><!--T:67--> Unarticulated annotation.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
|-
|-
|scope="row"| {{tag|ul|open}}
|scope="row"| {{tag|ul|open}}
| <translate><!--T:68--> Unordered list</translate>
| <translate><!--T:68--> Unordered list.</translate>
| data-sort-value="1" | 1.1
| data-sort-value="1" | 1.1
|
|
Line 263: Line 263:
|-
|-
|scope="row"| {{tag|wbr|open}}
|scope="row"| {{tag|wbr|open}}
| <translate><!--T:70--> Line break opportunity</translate>
| <translate><!--T:70--> Line break opportunity.</translate>
| data-sort-value="22" | 1.22
| data-sort-value="22" | 1.22
|
|
Line 311: Line 311:
|
|
|}
|}
<translate>


<translate>
== Use cases == <!--T:76-->
== Use cases == <!--T:76-->



Revision as of 21:56, 19 March 2025

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

Allowed HTML tags in MediaWiki software
Tag Meaning Allowed since… Notes
‎<abbr> Abbreviation 1.16
‎<b> Bring attention 1.1 Wikitext: three single quotes, e.g. Be careful to '''this text'''.
‎<bdi> Bidirectional isolate 1.20
‎<bdo> Bidirectional text override 1.22
‎<big> Make text bigger 1.1 ‎<big> is deprecated in HTML, but not in wikitext (T154067)
‎<blockquote> Block quotation 1.1
‎<br> Line break 1.1
‎<caption> Table caption 1.1
‎<cite> Citation, i.e. reference to a cited creative work. 1.1
‎<code> Inline computer code 1.1
‎<data> Data, linked to machine-readable translation through value attribute. 1.21
‎<dd> Description details for a description term element, inside a description list. 1.1 Wikitext: : starting the line, respectively for description list details.
‎<del> Deleted text 1.3
‎<dfn> Definition. Wrap a term/phrase which is being defined. 1.17
‎<div> Content division, to apply CSS formatting to a block. 1.1
‎<dl> Description list. 1.1
‎<dt> Description term, inside a description list. 1.1 Wikitext: ; starting the line, respectively for description list term.
‎<em> Emphasis 1.1
‎<h1> Section heading – levels 1 to 6 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 1.1 Wikitext: 4+ dashes (----) starting a line.
‎<i> Idiomatic text 1.1 Wikitext: two single quotes, e.g. ''idiomatic text''.
‎<ins> Added text 1.3
‎<kbd> Keyboard input 1.17
‎<li> List item 1.1 Wikitext: # or * starting the line, respectively for ordered list and unordered list.
‎<link> External resource link 1.27 Must have itemprop and href attributes set.[1] Excludes most values for rel, including the stylesheet value.
‎<mark> Marked or highlighted text. 1.21
‎<meta> Metadata 1.27 Must have itemprop and content attributes set.[1]
‎<ol> Ordered list 1.1
‎<p> Paragraph 1.1 Wikitext: text between empty lines.
‎<pre> Preformated text 1.1 Content is not parsed, as in a ‎<nowiki> tag.

Wikitext: line starting with a blank space, i.e.  preformated text.

‎<q> Inline quotation 1.22
‎<rp> Ruby fallback parenthesis 1.1
‎<rt> Ruby text: annotation rendered near the base text. Inside a ruby tag. 1.1
‎<ruby> Ruby annotation. Encloses rt and rp. 1.1
‎<s> Strikethrough, for no longer accurate or relevant text. 1.1
‎<samp> Sample output, inline ouput text of a computer program. 1.17
‎<small> Side comment. 1.1
‎<span> Content span, to apply CSS formatting to an inline text. 1.4
‎<strong> Strong importance. 1.1
‎<sub> Subscript 1.1
‎<sup> Superscript 1.1
‎<table> Table, for tabular data. 1.1 Wikitext: see help page about tables.
‎<td> Table data cell, inside a tr tag. 1.1 Wikitext: see help page about tables.
‎<th> Table header cell, inside a tr tag 1.1 Wikitext: see help page about tables.
‎<time> Date/Time 1.21
‎<tr> Table row, inside a table tag. 1.1 Wikitext: see help page about tables.
‎<u> Unarticulated annotation. 1.1
‎<ul> Unordered list. 1.1
‎<var> Variable 1.1
‎<wbr> Line break opportunity. 1.22

Deprecated tags

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.

HTML tags deprecated in MediaWiki
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

Anchor

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

With style attribute

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

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

HTML comments

Wikitext uses HTML comment syntax for its own comments: the parser ignores them, they are not rendered in resulting HTML source.

<!-- 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

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.

See also

References