Help:HTML in wikitext

For many HTML elements, more convenient wikitext code is available, see Help:Wiki markup, however there are some situations in which the HTML alternative is useful, for example creating an link to a particular element of a table.online writing jobs

Permitted HTML
The following HTML elements are currently permitted:

京(きょう)
 * &lt;abbr&gt;
 * Marks an abbreviation, and can make the full form available: abbr.
 * &lt;b&gt;
 * Sets font to boldface where possible
 * &lt;big&gt;
 * Increases font size
 * &lt;blockquote&gt;
 * A block-level quotation, "for when the quotation includes block level elements," e.g. paragraphs
 * &lt;br&gt;
 * A forced line-break
 * &lt;caption&gt;
 * &lt;center&gt;
 * Creates a block-level center-aligned division Use  instead
 * &lt;cite&gt;
 * A citation
 * &lt;code&gt;
 * &lt;dd&gt;
 * The definition of a term,in a definition list</dd></dl>
 * &lt;del&gt;
 * Deleted text
 * &lt;div&gt;
 * A block-level logical division
 * &lt;dl&gt;
 * <dl>A definition list (consisting of definition terms paired with definitions)</dl>
 * &lt;dt&gt;
 * <dl><dt>A definition term</dt><dt>in a definition list</dt></dl>
 * &lt;em&gt;
 * Emphasis
 * &lt;font&gt;
 * <font color="green" size="-1" face="Courier">Can specify the font color with the color attribute, typeface with the face attribute, and absolute or relative size with the size attribute. use  instead
 * &lt;h1&gt; - &lt;h6&gt;
 * Section headings at different levels.
 * &lt;hr&gt;
 * A horizontal rule
 * &lt;i&gt;
 * Sets font to italic where possible
 * &lt;ins&gt;
 * Inserted text
 * &lt;li&gt;
 * <li>A list item in ordered (ol)</li><li>or unordered (ul) lists</li>
 * &lt;ol&gt;
 * <ol><li>An ordered...</li><li>(enumerated) list</li></ol>
 * &lt;p&gt;
 * Creates a paragraph, perhaps the most common block level element
 * &lt;pre&gt;
 * a Pre-formatted text b
 * &lt;rb&gt;
 * 東 vs <ruby style="font-size:1.2em;">東</rb>
 * &lt;rp&gt;
 * ( vs <ruby style="font-size:1.2em;">(</rp>
 * &lt;rt&gt;
 * とう vs <ruby style="font-size:1.2em;">とう</rt>
 * &lt;ruby&gt;
 * 東(とう)京(きょう) vs <ruby style="font-size:1.2em;">東</rb>(</rp>とう</rt>)</rp>
 * &lt;ruby&gt;
 * 東(とう)京(きょう) vs <ruby style="font-size:1.2em;">東</rb>(</rp>とう</rt>)</rp>
 * &lt;s&gt;
 * Strike-through text
 * &lt;small&gt;
 * Decreases font size
 * &lt;span&gt;
 * An inline logical division
 * &lt;strike&gt;
 * Strike-through text
 * &lt;strong&gt;
 * &lt;sub&gt;
 * Marksubscript
 * &lt;sup&gt;
 * Marksuperscript
 * &lt;table&gt;
 * &lt;td&gt;
 * &lt;th&gt;
 * &lt;tr&gt;
 * &lt;tt&gt;
 * <tt>Fixed-width font</tt>
 * &lt;u&gt;
 * Underlines text
 * &lt;ul&gt;
 * <ul><li>An unordered...</li><li>(bulleted) list</li></ul>
 * &lt;var&gt;
 * Variable
 * &lt;!-- ... --&gt;
 * &lt;ul&gt;
 * <ul><li>An unordered...</li><li>(bulleted) list</li></ul>
 * &lt;var&gt;
 * Variable
 * &lt;!-- ... --&gt;

Anchors
HTML tags allow an  attribute that can be referenced in one's user style CSS, and allows the element to be used as link target.

However, the anchor element  is not allowed, so the wikitext is treated like the wikitext 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 (&lt;a&gt;) the wiki markup for external reference is required (enclosed in square brackets with the URL separated from the contents by a single space): displays as "Main Page"

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

Tags
is a generic inline text container.

is a similar tag which is deprecated (should not be used) in favor of  .''

For example produces the same result as

See also and m:Help:Text color.

It's pointless to combine the legacy tag <tt>&lt;font&gt;</tt> with inline CSS; legacy browsers would ignore the CSS, while modern browsers support <tt>&lt;span&gt;</tt> (see above).

Note that in most cases, one can use a more descriptive tag, for instance,  to indicate an important piece of text, or   (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.

Using as a link target
The standard way of providing a named anchor as an invisible target (i.e. ) doesn't work (since all   tags are converted), and an alternative suggested by the W3C, , produces an "[Edit]" link.

However,  does produce a target that can be the destination of a link. Note that it doesn't work everywhere; for instance, in a table, it has to be inside a cell before some browsers will jump to it properly.

is a generic block container. Rules:
 * should be followed by a newline
 * should be preceded by a newline
 * followed by text on the same line, two newlines and text before  on the same line should be avoided (because the two newlines only produce a space)

HTML comment
Using : The "Remove comments" option of ExpandTemplates selects whether comments are removed, not just in the final result but throughout the expansion process. This affects the result of parser functions: a comment in the expression of #expr or in the condition of #ifexpr gives an error message unless "Remove comments" is on, and comments affect #if and #ifeq.
 * t
 * " gives "&lt;!--t-->start-pqr-end", producing HTML code without the comment.

Example:

Wikitext:

Result of normal expansion, and of ExpandTemplates with "Remove comments" on:

Result of full substitution, and of ExpandTemplates with "Remove comments" off:

0

0

1

Therefore it is typically better to avoid comments in these places, and to put the comment before or after the parser function.

In the case of nested parser functions, to avoid having to put the comments outside the whole, an alternative is. In the case of substitution of the parser function, "void" has to be substituted too, e.g. in a template allowing multi-level substitution we can put.

Another alternative is making the comment the name of a parameter (in the likely case that it is unused), with the empty string as default, e.g. or, to recognize the intention, use pseudo comment tags:, or real ones, if the empty string is not used as parameter:.

See also.

Attributes
Most tags can have a <tt>style</tt> attribute. For example produces: <blockquote style="border:1px dotted gray; padding-left:20px"> 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

Example infobox Produces the box which floats on the right because <tt>infobox</tt> class is already defined in local Mediawiki:Common.css. <br style=clear:all>

Classes and IDs can also be used by Javascript code, for example see how {Link FA} works in enwiki.

Classes are also widely used to create microformats. See the microformats project for more information. Some class names are reserved for use in microformats.

Another attribute example is <tt>title</tt>, for example used in H:title template: note the hover box over "20000 ft" <blockquote style="border:1px dotted gray; padding-left:20px"> "a height of 20000 ft above sea level"

Pre
tags work as the combination of  and the standard HTML   tag: the content will preformatted, and it will not be parsed, but shown as in the wikitext source. If you want preformatted but parsed text, use a space in the beginning of the line instead. For example,

This word is bold. This word is bold. will render as

This word is bold. This word is bold.

Comments
HTML comments in the wikitext will not appear in the HTML code at all.

Headers
Headers ( ... ) will be treated in a similar way as wikicode headers:

sample header

Note that it appears in the table of contents and has an accompanying edit link. There are some minor differences though: editing such a section won't prefill the edit summary, and the browser won't jump to the beginning of the section when saving the page. Thus, you should use the wikitext equivalents instead.

Exceptions
In some pages in the MediaWiki namespace (typically the short messages like button labels) HTML does not work, and e.g. &lt;span id=abc&gt; produces the HTML &amp;lt;span id=abc&amp;gt; rendered by the browser as &lt;span id=abc&gt;. Some others are interpreted as pure HTML (thus any tag can be used, but wikicode won't be transformed to HTML).

User CSS and JS pages (see Help:User style) are interpreted as if inside a  block. From MW 1.11 this also goes for sitewide CSS/JS; in earlier versions, you have to manually add <tt> /* */ </tt> to the beginning and <tt> /* */ </tt> to the end of those pages to avoid strange rendering.

Validation
The MediaWiki software attempts to catch HTML errors, but it does not catch all of them. If you use HTML in wikitext, it is helpful to verify it with the W3C Markup Validation Service.