Changes

Jump to: navigation, search

Help:HTML in wikitext

5,343 bytes added, 22:26, January 28, 2005
Another import.
==Permitted HTML==
The following [[w:HTML element|HTML element]]s are currently permitted:

{| border="0" cellpadding="5"
| valign="top"|
* <b>
* <big>
* <blockquote>
* <br>
* <caption>
* <center>
* <cite>
* <code>
* <dd>
* <div>
* <dl>
* <dt>
* <em>
* <font>
* <h1>
| valign="top"|
* <h2>
* <h3>
* <h4>
* <h5>
* <h6>
* <hr>
* <i>
* <li>
* <ol>
* <p>
* <pre>
* <rb>
* <rp>
* <rt>
* <ruby>
| valign="top"|
* <s>
* <small>
* <strike>
* <strong>
* <sub>
* <sup>
* <table>
* <td>
* <th>
* <tr>
* <tt>
* <u>
* <ul>
* <var>
* <!-- ... -->
|}


The following excerpt from [http://cvs.sourceforge.net/viewcvs.py/wikipedia/phpwiki/newcodebase/OutputPage.php OutputPage.php] additionally shows which attributes are allowed. 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.

<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="meta.wikimedia.org/wiki/Main_Page">Main Page</a>

produces the HTML code

&amp;lt;a href="meta.wikimedia.org/wiki/Main_Page"&amp;gt;Main Page&amp;lt;/a&amp;gt;

which renders as the wikitext, not working as a link.

==Span==

Span is also allowed now. See [[en:Wikipedia:Span tags]].

The replacement &lt;div style="display:inline"> can also be used, but, oddly, apparently only in a list:

<pre>
*a <div style="display:inline; color:red">red </div> word

#a <div style="display:inline; color:red">red </div> word

a <div style="display:inline; color:red">red </div> word
</pre>

gives

*a <div style="display:inline; color:red">red </div> word

#a <div style="display:inline; color:red">red </div> word

a <div style="display:inline; color:red">red </div> word

Outside a list "display:inline" is effectively disabled: the code is retained, but with closure of the paragraph before the styled part and starting a new one after it.

Note that the blank spaces at the end of and just after the styled part are removed; use &amp;nbsp; at the end:

<pre>
*a <div style="display:inline; color:red">red &amp;nbsp;</div>word
</pre>

gives

*a <div style="display:inline; color:red">red&nbsp;</div>word

==Font==

For some attributes, like color, one can also use

<pre>
a <font style="color: red">red</font> word
</pre>

or

<pre>
a <font color=red>red</font> word.
</pre>

giving

a <font style="color: red">red</font> word

a <font color=red>red</font> word

The font element can even be used to replace span, e.g.

<nowiki>a height of 20000 <font title="30.48 cm" class="title">ft</font> above sea level</nowiki>

giving

a height of 20000 <font title="30.48 cm" class="title">ft</font> above sea level

(note the hover box over "ft").

Use a css line like

.title {color: red; }

to see which text has a hover box.

==Div==

E.g. to assign the class "red" to a text one can put

&lt;div class="red">example text&lt;/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, specially adapted for such usage, 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]

[[Category:OrthodoxWiki]]
Bureaucrats, Check users, interwiki, oversight, renameuser, Administrators
7,276
edits

Navigation menu