Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Help:HTML in wikitext

From mediawiki.org
Translate this page
Languages:
PDNote: When you edit this page, you agree to release your contribution under theCC0. SeePublic Domain Help Pages for more info.PD

MediaWiki is able to parse someHTML tags in wikitext. Brackets for other tags are escaped and the tags are displayed instead of being parsed.

Allowed HTML tags and attributes

[edit]
Allowed HTML tags and attributes in MediaWiki software
TagMeaningAllowed attributesTag allowed since…Notes
‎<abbr>Abbreviationcommon attributes1.16
‎<b>Bring attentioncommon attributes1.1Wikitext: three single quotes, e.g.Be careful to '''this text'''.
‎<bdi>Bidirectional isolatecommon attributes1.20
‎<bdo>Bidirectional text overridecommon attributes1.22
‎<big>Make text biggercommon attributes1.1‎<big> is deprecated in HTML, but not in wikitext (T154067)
‎<blockquote>Block quotationcommon attributes +cite1.1
‎<br>Line breakcommon attributes +clear1.1
‎<caption>Table captioncommon attributes +align1.1
‎<cite>Citation, i.e. reference to a cited creative work.common attributes1.1
‎<code>Inline computer codecommon attributes1.1
‎<col>common attributes +span
‎<colgroup>common attributes +span
‎<data>Data, linked to machine-readable translation throughvalue attribute.common attributes +value1.21
‎<dd>Description details for a description term element, inside a description list.common attributes1.1Wikitext:: starting the line, respectively for description list details.
‎<del>Deleted textcommon attributes +cite,datetime1.3
‎<dfn>Definition. Wrap a term/phrase which is being defined.common attributes1.17
‎<div>Content division, to apply CSS formatting to a block.common attributes +align1.1
‎<dl>Description list.common attributes1.1
‎<dt>Description term, inside a description list.common attributes1.1Wikitext:; starting the line, respectively for description list term.
‎<em>Emphasiscommon attributes1.1
‎<h1>Section heading – levels 1 to 6common attributes +align1.1Wikitext: pairs of equal signs (seehelp about formatting).

Note when you edit a section headed by an HTML heading, the edit summary willnot be prefilled.

‎<hr>Thematic breakcommon attributes +width1.1Wikitext: 4+ dashes (----) starting a line.
‎<i>Idiomatic textcommon attributes1.1Wikitext: two single quotes, e.g.''idiomatic text''.
‎<ins>Added textcommon attributes +cite,datetime1.3
‎<kbd>Keyboard inputcommon attributes1.17
‎<li>List itemcommon attributes +type,value1.1Wikitext:# or* starting the line, respectively for ordered list and unordered list.
‎<link>External resource linkitemprop,href,title1.27Must haveitemprop andhref attributes set.[1]Excludes most values forrel, including thestylesheet value.
‎<mark>Marked or highlighted text.common attributes1.21
‎<meta>Metadataitemprop,content1.27Must haveitemprop andcontent attributes set.[1]
‎<ol>Ordered listcommon attributes +type,start,reversed1.1
‎<p>Paragraphcommon attributes +align1.1Wikitext: text between empty lines.
‎<pre>Preformatted textcommon attributes +width1.1Content is not parsed, as in a‎<nowiki> tag.

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

‎<q>Inline quotationcommon attributes +cite1.22
‎<rp>Ruby fallback parenthesiscommon attributes1.1
‎<rt>Ruby text: annotation rendered near the base text. Inside aruby tag.common attributes1.1
‎<ruby>Ruby annotation. Enclosesrt andrp.common attributes1.1
‎<s>Strikethrough, for no longer accurate or relevant text.common attributes1.1
‎<samp>Sample output, inline ouput text of a computer program.common attributes1.17
‎<small>Side comment.common attributes1.1
‎<span>Content span, to apply CSS formatting to an inline text.common attributes1.4
‎<strong>Strong importance.common attributes1.1
‎<sub>Subscriptcommon attributes1.1
‎<sup>Superscriptcommon attributes1.1
‎<table>Table, for tabular data.common attributes +summary,width,border,frame,rules,cellspacing,cellpadding,align,bgcolor1.1Wikitext:see help page about tables.
‎<td>Table data cell, inside atr tag.common attributes +abbr,axis,headers,scope,rowspan,colspan,nowrap,width,height,bgcolor,align,valign1.1Wikitext:see help page about tables.
‎<th>Table header cell, inside atr tagcommon attributes +abbr,axis,headers,scope,rowspan,colspan,nowrap,width,height,bgcolor,align,valign1.1Wikitext:see help page about tables.
‎<time>Date/Timecommon attributes +datetime1.21
‎<tr>Table row, inside atable tag.common attributes +bgcolor,align,valign1.1Wikitext:see help page about tables.
‎<u>Unarticulated annotation.common attributes1.1
‎<ul>Unordered list.common attributes +type1.1
‎<var>Variablecommon attributes1.1
‎<wbr>Line break opportunity.common attributes1.22

Common attributes

[edit]

The following attributes are permitted on almost all tags listed in the table above (exceptmeta andlink):

  • HTML
    • id
    • class
    • style
    • lang
    • dir
    • title
    • tabindex
  • WAI-ARIA
    • aria-describedby
    • aria-flowto
    • aria-hidden
    • aria-label
    • aria-labelledby
    • aria-level
    • aria-owns
    • role
  • RDFa
    • about
    • property
    • resource
    • datatype
    • typeof
  • Microdata
    • itemid
    • itemprop
    • itemref
    • itemscope
    • itemtype

Deprecated tags

[edit]

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 astyle attribute to reproduce the expected display.

HTML tags deprecated in MediaWiki
TagAllowed since…EmitsLint error?Notes
‎<center>1.1Yes
‎<font>1.1Yes
‎<rb>1.1No
‎<rtc>1.24No
‎<strike>1.1Yes
‎<tt>1.1Yes

Use cases

[edit]

Anchor

[edit]

To create alinkable anchor, you can use any HTML tag with anid attribute.

E.g.<spanid="note2"></span> allows you to create a link to its location on the page using[[#note2|See relevant note]].

CSS formatting

[edit]

Withstyle attribute

[edit]

Using HTML tag instead of wikitext equivalent allows you to add astyle attribute to define a custom display throughCSS language.

Withclass andid attributes

[edit]

Thanks toTemplateStyles, you may add a custom stylesheet to the document.So it is useful to addclass orid attributes to the elements you want to customize their display.

Overridden HTML syntax

[edit]

HTML comments

[edit]

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

[edit]

The content of apre 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

[edit]
  • 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.

References

[edit]
  1. 1.01.1Parser\Sanitizer::validateTag()
Retrieved from "https://www.mediawiki.org/w/index.php?title=Help:HTML_in_wikitext&oldid=7717997"

[8]ページ先頭

©2009-2025 Movatter.jp