Help:HTML in wikitext

From OrthodoxWiki
(Difference between revisions)
Jump to: navigation, search
m (Span: fix link)
 
(One intermediate revision by one user not shown)
Line 4: Line 4:
 
{| border="0" cellpadding="5"
 
{| border="0" cellpadding="5"
 
| valign="top"|
 
| valign="top"|
* <b>
+
* [[Wikipedia:HTML_element#Presentational_markup|<b>]]
* <big>
+
* [[Wikipedia:HTML_element#Presentational_markup|<big>]]
* <blockquote>
+
* [[Wikipedia:HTML_element#TAext_containers|<blockquote>]]
* <br>
+
* [[Wikipedia:HTML_element#Others|<br>]]
* <caption>
+
* [[Wikipedia:HTML_element#Tables|<caption>]]
 
* <center>
 
* <center>
 
* <cite>
 
* <cite>
* <code>
+
* [[Wikipedia:HTML_element#Logical_markup|<code>]]
* <dd>
+
* [[Wikipedia:HTML_element#Lists|<dd>]]
* <div>
+
* [[Wikipedia:HTML_element#Other_containers|<div>]]
* <dl>
+
* [[Wikipedia:HTML_element#Lists|<dl>]]
* <dt>
+
* [[Wikipedia:HTML_element#Lists|<dt>]]
* <em>
+
* [[Wikipedia:HTML_element#Logical_markup|<em>]]
* <font>
+
* [[Wikipedia:HTML_element#Presentational_markup|<font>]]
* <h1>
+
* [[Wikipedia:HTML_element#Headings|<h1>]]
 
| valign="top"|
 
| valign="top"|
* <h2>
+
* [[Wikipedia:HTML_element#Headings|<h2>]]
* <h3>
+
* [[Wikipedia:HTML_element#Headings|<h3>]]
* <h4>
+
* [[Wikipedia:HTML_element#Headings|<h4>]]
* <h5>
+
* [[Wikipedia:HTML_element#Headings|<h5>]]
* <h6>
+
* [[Wikipedia:HTML_element#Headings|<h6>]]
* <hr>
+
* [[Wikipedia:HTML_element#Other_containers|<hr>]]
* <i>
+
* [[Wikipedia:HTML_element#Presentational_markup|<i>]]
* <li>
+
* [[Wikipedia:HTML_element#Lists|<li>]]
* <ol>
+
* [[Wikipedia:HTML_element#Lists|<ol>]]
* <p>
+
* [[Wikipedia:HTML_element#Text_containers|<p>]]
* <pre>
+
* [[Wikipedia:HTML_element#Text_containers|<pre>]]
 
* <rb>
 
* <rb>
 
* <rp>
 
* <rp>
Line 36: Line 36:
 
* <ruby>
 
* <ruby>
 
| valign="top"|
 
| valign="top"|
* <s>
+
* [[Wikipedia:HTML_element#Presentational_markup|<s>]]
* <small>
+
* [[Wikipedia:HTML_element#Presentational_markup|<small>]]
* <strike>
+
* [[Wikipedia:HTML_element#Presentational_markup|<strike>]]
* <strong>
+
* [[Wikipedia:HTML_element#Logical_markup|<strong>]]
* <sub>
+
* [[Wikipedia:HTML_element#Presentational_markup|<sub>]]
* <sup>
+
* [[Wikipedia:HTML_element#Presentational_markup|<sup>]]
* <table>
+
* [[Wikipedia:HTML_element#Tables|<table>]]
* <td>
+
* [[Wikipedia:HTML_element#Tables|<td>]]
* <th>
+
* [[Wikipedia:HTML_element#Tables|<th>]]
* <tr>
+
* [[Wikipedia:HTML_element#Tables|<tr>]]
* <tt>
+
* [[Wikipedia:HTML_element#Presentational_markup|<tt>]]
* <u>
+
* [[Wikipedia:HTML_element#Presentational_markup|<u>]]
* <ul>
+
* [[Wikipedia:HTML_element#Lists|<ul>]]
* <var>
+
* [[Wikipedia:HTML_element#Logical_markup|<var>]]
* <!-- ... -->
+
* [[Wikipedia:HTML_element#Others|<!-- ... -->]]
 
|}
 
|}
  
Line 107: Line 107:
 
==Span==
 
==Span==
  
Span is also allowed now. See [[en:Wikipedia:Span tags]].
+
Span is also allowed now. See [[Wikipedia:Span tags]].
  
 
The replacement <div style="display:inline"> can also be used, but, oddly, apparently only in a list:
 
The replacement <div style="display:inline"> can also be used, but, oddly, apparently only in a list:

Latest revision as of 10:25, October 20, 2009

Contents

Permitted HTML

The following HTML elements are currently permitted:


The following excerpt from 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.

	/* 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 */
		);

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

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

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

Span

Span is also allowed now. See Wikipedia:Span tags.

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

*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

gives

  • a
    red
    word
  1. a
    red
    word
a
red
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 &nbsp; at the end:

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

gives

  • a
    red 
    word

Font

For some attributes, like color, one can also use

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

or

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

giving

a red word

a red word

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

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

giving

a height of 20000 ft 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

<div class="red">example text</div>
which gives
example text
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

Personal tools
Namespaces
Variants
Actions
Navigation
interaction
Donate

Please consider supporting OrthodoxWiki. FAQs

Toolbox