Help:HTML in wikitext
From ThermoWiki
Contents |
Permitted HTML
The following HTML elements are currently permitted:
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.
For example, the anchor element <a> is not allowed, so the wikitext
-
<a href="http://meta.wikimedia.org/">Main Page</a>
is treated like the wikitext
-
<a href="http://meta.wikimedia.org/">Main Page</a>
and is therefore displayed as
- <a href="http://meta.wikimedia.org/">Main Page</a>
which is unlikely to be what the editor intended. Instead of using the anchor element (<a>) the wiki markup for external reference is recommended (enclosed in square brackets with the URL separated from the contents by a single space):
-
[http://meta.wikimedia.org/ Main Page]
displays as:
The following excerpt from Sanitizer.php additionally shows which attributes are allowed.
<source lang=php> $htmlpairs = array( # Tags that must be closed
'b', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'cite', 'code', 'em', 's', 'strike', 'strong', 'tt', 'var', 'div', 'center', 'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre', 'ruby', 'rt' , 'rb' , 'rp', 'p', 'span' );
$htmlsingle = array(
'br', 'hr', 'li', 'dt', 'dd' );
$htmlsingleonly = array( # Elements that cannot have close tags
'br', 'hr' );
$htmlnest = array( # Tags that can be nested--??
'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul', 'dl', 'font', 'big', 'small', 'sub', 'sup', 'span' );
$tabletags = array( # Can only appear inside table
'td', 'th', 'tr' );
</source>
Tags
Template:Mlw is a generic inline text container.
<font> is a similar tag which is deprecated (should not be used) in favor of <span>.
For example <source lang=html4strict> a red word. </source> produces the same result as <source lang=html4strict> a red word. </source>
It's pointless to combine the legacy tag <font> with inline CSS; legacy browsers would ignore the CSS, while modern browsers support <span> (see above).
<div> is a generic block container.
Note that in most cases, one can use a more descriptive tag, for instance, <strong> to indicate an important piece of text, or <em> (subject to the same things as strong) to indicate an emphasized piece of 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.
Attributes
Most tags can have a style attribute. For example <source lang=html4strict>
This is red text.
</source> produces:
This is red text.
Most tags can have classes and IDs. They can be 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.
For example
<source lang=html4strict>
</source>
Produces the box which floats on the right because infobox class is already defined in local Mediawiki:Common.css.
Classes and IDs can also be used by Javascript code, for example see how {Link FA} works in enwiki.
Another attribute example is title, for example used in Template:Tl template: note the hover box over "20000 ft"
"a height of Template:H:title above sea level"
Exceptions
In some pages in the MediaWiki namespace HTML does not work, and e.g. <span id=abc> produces the HTML <span id=abc> rendered by the browser as <span id=abc>.
CSS and JS pages (see Help:User style) are not interpreted as wikitext, and therefore can have arbitrary HTML.

