Help:HTML in wikitext

This is a copy of the master help page at m:Help:HTML in wikitext. Do not edit this page. Edits will be lost in the next update from the master page. Either edit the master help page for all projects at Meta, or edit the project-specific text at Template:Ph:HTML in wikitext. You are welcome to copy the exact wikitext from the master page at Meta and paste it into this page at any time.

The following excerpt from OutputPage.php additionally shows which attributes are allowed.

Update: In 1.4rc1, the removeHTMLtags function is located in Parser.php.

Update: In 1.5, the removeHTMLtags function is now located in Sanitizer.php.

For many HTML elements, more convenient wikitext code is available, see Help:Editing. On the other hand, HTML tags allow an id that can be referenced in one's user style css, and allows the tag to be used as link target.

<span>, a generic inline text container, is now allowed on default MediaWiki installations (as of version 1.5). Span can be ID'd, classed, or styled:

This is <span style="color:red">red</span> text.
This is <span id="randomfooid">identified</span> text.
This is <span class="importantmessage">classed</span> text.

produces:

This is red text.

This is identified text.

This is classed text.

IDs and classes are used in conjunction with stylesheets to give a piece of text a descriptive class (or unique identifier) and to refer to that in a stylesheet.

Note that in most cases, one can use a more descriptive tag, for instance, <strong> (which can be classed, identified, and styled, as well) to indicate an important piece of text, or <em> (subject to the same things as strong) to indicate an emphasized piece of text. For instance, the above might be better reformulated as

This is <em style="color:red;font-style:normal">red</em> text.

This is red text.

This not only draws the user's attention to the text, but can also alert those who are using nonvisual browsers or have sight impairments, etc. to the fact that that is emphasized text.

This is suitable if the color is specifically intended to be red; if it is just for emphasis a more general term for the class would be more appropriate, because css allows the user to choose another method of emphasis (another color, bold, enlarged, etc.).

Note that many readers will not have their own css with such lines as ".red {color:red}", so one cannot refer to "the red text above", etc.