Changes
{{H:h|editor toc}}
==Permitted HTML==
The following [[w:HTML element|HTML element]]s are currently permitted:
{| border="0" cellpadding="5"
| valign="top"|
* [[w:HTML_element#Presentational_markup|<b>]]
* [[w:HTML_element#Presentational_markup|<big>]]
* [[w:HTML_element#Text_containers|<blockquote>]]
* [[w:HTML_element#Others|<br>]]
* [[w:HTML_element#Tables|<caption>]]
* <center>
* <cite>
* [[w:HTML_element#Structured_text|<code>]]
* [[w:HTML_element#Lists|<dd>]]
* [[w:HTML_element#Other_containers|<div>]]
* [[w:HTML_element#Lists|<dl>]]
* [[w:HTML_element#Lists|<dt>]]
* [[w:HTML_element#Structured_text|<em>]]
* [[w:HTML_element#Presentational_markup|<font>]]
* [[w:HTML_element#Headings|<h1>]]
| valign="top"|
* [[w:HTML_element#Headings|<h2>]]
* [[w:HTML_element#Headings|<h3>]]
* [[w:HTML_element#Headings|<h4>]]
* [[w:HTML_element#Headings|<h5>]]
* [[w:HTML_element#Headings|<h6>]]
* [[w:HTML_element#Other_containers|<hr>]]
* [[w:HTML_element#Presentational_markup|<i>]]
* [[w:HTML_element#Lists|<li>]]
* [[w:HTML_element#Lists|<ol>]]
* [[w:HTML_element#Text_containers|<p>]]
* [[w:HTML_element#Text_containers|<pre>]]
* <rb>
* <rp>
* <rt>
* <ruby>
| valign="top"|
* [[w:HTML_element#Presentational_markup|<s>]]
* [[w:HTML_element#Presentational_markup|<small>]]
* [[w:HTML_element#Other_containers|<span>]]
* [[w:HTML_element#Presentational_markup|<strike>]]
* [[w:HTML_element#Structured_text|<strong>]]
* [[w:HTML_element#Presentational_markup|<sub>]]
* [[w:HTML_element#Presentational_markup|<sup>]]
* [[w:HTML_element#Tables|<table>]]
* [[w:HTML_element#Tables|<td>]]
* [[w:HTML_element#Tables|<th>]]
* [[w:HTML_element#Tables|<tr>]]
* [[w:HTML_element#Presentational_markup|<tt>]]
* [[w:HTML_element#Presentational_markup|<u>]]
* [[w:HTML_element#Lists|<ul>]]
* [[w:HTML_element#Structured_text|<var>]]
* [[w:HTML_element#Others|<!-- ... -->]]
|}
The following excerpt from [svn.wikimedia.org/viewvc/mediawiki/tags/REL1_6_6/phase3/includes/Sanitizer.php Sanitizer.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 [[Help:User style|user style]] css, and allows the tag to be used as link target.
<br clear="all"><!-- stop floating navbox before pre -->
<pre>
/* private */ function removeHTMLtags( $text )
{
wfProfileIn( "OutputPage::removeHTMLtags" );
$htmlpairs = array( # Tags that must be closed
"b", "i", "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"
);
$htmlsingle = array(
"br", "p", "hr", "li", "dt", "dd"
);
$htmlnest = array( # Tags that can be nested--??
"table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
"dl", "font", "big", "small", "sub", "sup"
);
$tabletags = array( # Can only appear inside table
"td", "th", "tr"
);
$htmlsingle = array_merge( $tabletags, $htmlsingle );
$htmlelements = array_merge( $htmlsingle, $htmlpairs );
$htmlattrs = array( # Allowed attributes--no scripting, etc.
"title", "align", "lang", "dir", "width", "height",
"bgcolor", "clear", /* BR */ "noshade", /* HR */
"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
/* FONT */ "type", "start", "value", "compact",
/* For various lists, mostly deprecated but safe */
"summary", "width", "border", "frame", "rules",
"cellspacing", "cellpadding", "valign", "char",
"charoff", "colgroup", "col", "span", "abbr", "axis",
"headers", "scope", "rowspan", "colspan", /* Tables */
"id", "class", "name", "style" /* For CSS */
);
</pre>
E.g., element "a" is not allowed, and the wikitext
<a href="<nowiki>http://meta.wikimedia.org/wiki/Main_Page</nowiki>">Main Page</a>
produces the HTML code
&lt;a href="<nowiki>http://meta.wikimedia.org/wiki/Main_Page</nowiki>"&gt;Main Page&lt;/a&gt;
which renders as the wikitext, not working as a link.
==Span==
<code><nowiki><span></nowiki></code>, 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:
<nowiki>This is <span style="color:red">red</span> text.</nowiki>
<nowiki>This is <span id="randomfooid">identified</span> text.</nowiki>
<nowiki>This is <span class="importantmessage">classed</span> text.</nowiki>
produces:
<blockquote>
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.
</blockquote>
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><nowiki><strong></nowiki></strong> (which can be classed, identified, and styled, as well) to indicate an important piece of text, or <em><nowiki><em></nowiki></em> (subject to the same things as strong) to indicate an emphasized piece of text. For instance, the above might be better reformulated as
<nowiki>This is <em style="color:red;font-style:normal">red</em> text.</nowiki>
<blockquote>This is <em style="color:red;font-style:normal">red</em> text.</blockquote>
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 <em>emphasized text</em>.
Using {{timc|H:title}}, <nowiki>"a height of {{h:title|6.1 km|20000 ft}} above sea level"</nowiki> gives "a height of {{h:title|6.1 km|20000 ft}} above sea level" (note the hover box over "20000 ft").
==Font==
''Note: This element is [[w:Deprecation|deprecate]]d (should not be used) in favor of [[#Span|<nowiki><span></nowiki>]].''
For some attributes, like color, one can also use
<pre>
a <font color="red">red</font> word.
</pre>
giving
a <font color="red">red</font> word
It's pointless to combine the legacy tag <tt><font></tt>
with inline CSS; legacy browsers would ignore the CSS, while
modern browsers support <tt><span></tt> (see above).
==Div==
E.g. to assign the class "red" to a text one can put
<div class="red">example text</div>
which gives <div class="red">example text</div> which is in red if the css line
.red {color:red}
is applicable.
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.
==External links==
* [http://www.w3.org/TR/html401/index/elements.html elements] | [http://www.w3.org/TR/html401/index/attributes.html attributes]
{{H:f|langs=|enname=HTML in wikitext}}
==Permitted HTML==
The following [[w:HTML element|HTML element]]s are currently permitted:
{| border="0" cellpadding="5"
| valign="top"|
* [[w:HTML_element#Presentational_markup|<b>]]
* [[w:HTML_element#Presentational_markup|<big>]]
* [[w:HTML_element#Text_containers|<blockquote>]]
* [[w:HTML_element#Others|<br>]]
* [[w:HTML_element#Tables|<caption>]]
* <center>
* <cite>
* [[w:HTML_element#Structured_text|<code>]]
* [[w:HTML_element#Lists|<dd>]]
* [[w:HTML_element#Other_containers|<div>]]
* [[w:HTML_element#Lists|<dl>]]
* [[w:HTML_element#Lists|<dt>]]
* [[w:HTML_element#Structured_text|<em>]]
* [[w:HTML_element#Presentational_markup|<font>]]
* [[w:HTML_element#Headings|<h1>]]
| valign="top"|
* [[w:HTML_element#Headings|<h2>]]
* [[w:HTML_element#Headings|<h3>]]
* [[w:HTML_element#Headings|<h4>]]
* [[w:HTML_element#Headings|<h5>]]
* [[w:HTML_element#Headings|<h6>]]
* [[w:HTML_element#Other_containers|<hr>]]
* [[w:HTML_element#Presentational_markup|<i>]]
* [[w:HTML_element#Lists|<li>]]
* [[w:HTML_element#Lists|<ol>]]
* [[w:HTML_element#Text_containers|<p>]]
* [[w:HTML_element#Text_containers|<pre>]]
* <rb>
* <rp>
* <rt>
* <ruby>
| valign="top"|
* [[w:HTML_element#Presentational_markup|<s>]]
* [[w:HTML_element#Presentational_markup|<small>]]
* [[w:HTML_element#Other_containers|<span>]]
* [[w:HTML_element#Presentational_markup|<strike>]]
* [[w:HTML_element#Structured_text|<strong>]]
* [[w:HTML_element#Presentational_markup|<sub>]]
* [[w:HTML_element#Presentational_markup|<sup>]]
* [[w:HTML_element#Tables|<table>]]
* [[w:HTML_element#Tables|<td>]]
* [[w:HTML_element#Tables|<th>]]
* [[w:HTML_element#Tables|<tr>]]
* [[w:HTML_element#Presentational_markup|<tt>]]
* [[w:HTML_element#Presentational_markup|<u>]]
* [[w:HTML_element#Lists|<ul>]]
* [[w:HTML_element#Structured_text|<var>]]
* [[w:HTML_element#Others|<!-- ... -->]]
|}
The following excerpt from [svn.wikimedia.org/viewvc/mediawiki/tags/REL1_6_6/phase3/includes/Sanitizer.php Sanitizer.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 [[Help:User style|user style]] css, and allows the tag to be used as link target.
<br clear="all"><!-- stop floating navbox before pre -->
<pre>
/* private */ function removeHTMLtags( $text )
{
wfProfileIn( "OutputPage::removeHTMLtags" );
$htmlpairs = array( # Tags that must be closed
"b", "i", "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"
);
$htmlsingle = array(
"br", "p", "hr", "li", "dt", "dd"
);
$htmlnest = array( # Tags that can be nested--??
"table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
"dl", "font", "big", "small", "sub", "sup"
);
$tabletags = array( # Can only appear inside table
"td", "th", "tr"
);
$htmlsingle = array_merge( $tabletags, $htmlsingle );
$htmlelements = array_merge( $htmlsingle, $htmlpairs );
$htmlattrs = array( # Allowed attributes--no scripting, etc.
"title", "align", "lang", "dir", "width", "height",
"bgcolor", "clear", /* BR */ "noshade", /* HR */
"cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
/* FONT */ "type", "start", "value", "compact",
/* For various lists, mostly deprecated but safe */
"summary", "width", "border", "frame", "rules",
"cellspacing", "cellpadding", "valign", "char",
"charoff", "colgroup", "col", "span", "abbr", "axis",
"headers", "scope", "rowspan", "colspan", /* Tables */
"id", "class", "name", "style" /* For CSS */
);
</pre>
E.g., element "a" is not allowed, and the wikitext
<a href="<nowiki>http://meta.wikimedia.org/wiki/Main_Page</nowiki>">Main Page</a>
produces the HTML code
&lt;a href="<nowiki>http://meta.wikimedia.org/wiki/Main_Page</nowiki>"&gt;Main Page&lt;/a&gt;
which renders as the wikitext, not working as a link.
==Span==
<code><nowiki><span></nowiki></code>, 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:
<nowiki>This is <span style="color:red">red</span> text.</nowiki>
<nowiki>This is <span id="randomfooid">identified</span> text.</nowiki>
<nowiki>This is <span class="importantmessage">classed</span> text.</nowiki>
produces:
<blockquote>
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.
</blockquote>
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><nowiki><strong></nowiki></strong> (which can be classed, identified, and styled, as well) to indicate an important piece of text, or <em><nowiki><em></nowiki></em> (subject to the same things as strong) to indicate an emphasized piece of text. For instance, the above might be better reformulated as
<nowiki>This is <em style="color:red;font-style:normal">red</em> text.</nowiki>
<blockquote>This is <em style="color:red;font-style:normal">red</em> text.</blockquote>
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 <em>emphasized text</em>.
Using {{timc|H:title}}, <nowiki>"a height of {{h:title|6.1 km|20000 ft}} above sea level"</nowiki> gives "a height of {{h:title|6.1 km|20000 ft}} above sea level" (note the hover box over "20000 ft").
==Font==
''Note: This element is [[w:Deprecation|deprecate]]d (should not be used) in favor of [[#Span|<nowiki><span></nowiki>]].''
For some attributes, like color, one can also use
<pre>
a <font color="red">red</font> word.
</pre>
giving
a <font color="red">red</font> word
It's pointless to combine the legacy tag <tt><font></tt>
with inline CSS; legacy browsers would ignore the CSS, while
modern browsers support <tt><span></tt> (see above).
==Div==
E.g. to assign the class "red" to a text one can put
<div class="red">example text</div>
which gives <div class="red">example text</div> which is in red if the css line
.red {color:red}
is applicable.
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.
==External links==
* [http://www.w3.org/TR/html401/index/elements.html elements] | [http://www.w3.org/TR/html401/index/attributes.html attributes]
{{H:f|langs=|enname=HTML in wikitext}}