Help:HTML in wikitext

From Absit Omen Lexicon

Template:Wikipedia how to Template:Wiki markup Template:HTML

The MediaWiki software, which drives the Lexicon, allows the use of a subset of HTML5 elements, or tags and their attributes, for presentation formatting. But most HTML can be included by using equivalent wiki markup or templates; these are preferred within articles, as they are simpler for most editors, and less intrusive in the editing window. For help with Cascading Style Sheet use within Wikipedia see Help:Cascading Style Sheets.

Some tags look like HTML, but are actually MediaWiki parser and extension tags, and so are really wiki markup..

Tutorials

This help page gives only an overview of allowed markup. For further assistance and detailed specifications:

Attributes

HTML attributes provide additional information about an element and are always specified in the start tag. They are formatted as a name/value pair like name="value".

Global attributes apply to all tags. Attributes not listed here are not allowed by MediaWiki:

  • class: one or more classifications to which the element belongs. See Absit Omen Lexicon:Catalogue of CSS classes.
  • dir: text direction— "ltr" (left-to-right), "rtl" (right-to-left) or "auto".
  • id: unique identifier for the element.
  • style: applies CSS styling to the contents of the element.
  • title: advisory information associated with the element.

HTML5 microdata attributes apply to all tags:

  • Any attribute beginning with data-
  • itemid
  • itemprop
  • itemref
  • itemscope
  • itemtype

Other tags such as <table> support specific attributes – these are listed in the appropriate section.

Markup Renders as
This is <span style="color:red">red</span> text. 
This is red text.

The MediaWiki sanitizer.php does some cleanup on attributes. A best practice is to use the proper syntax.

  • Discards attributes not on a whitelist for the given element.
  • Turns broken or invalid entities into plaintext.
  • Double-quotes all attribute values.
  • Attributes without values are given the name as value.
  • Double attributes are discarded.
  • Unsafe style attributes are discarded.
  • Prepends space if there are attributes.

Elements

These HTML elements are supported by the MediaWiki software. This section gives a brief overview of the HTML element, an example, relevant wikimarkup and templates.

Basic

h1, h2, h3, h4, h5, h6

Further information: Help:Section

The <h1>...</h1> through <h6>...</h6> tags are headings for the sections with which they are associated. <h1> is used for the article title. Headings are styled through CSS and added to the page's table of contents.

Markup Renders as
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6> 
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6

Wikimarkup: surround the text with the appropriate number of equal signs. Headers formatted with wikimarkup add an [edit] link.

Markup Renders as
= Heading 1 =
== Heading 2 ==
=== Heading 3 ===
==== Heading 4 ====
===== Heading 5 =====
====== Heading 6 ======
 
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6

Wiki headers use the following default CSS:

Wikimarkup HTML Style
= Heading = <h1> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.8em; font-family: Georgia,Times,serif; margin-top: 1em; margin-bottom: 0.25em; line-height: 1.3; padding: 0; border-bottom: 1px solid #AAAAAA;</source>
== Heading == <h2> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.5em; font-family: Georgia,Times,serif; margin-top: 1em; margin-bottom: 0.25em; line-height: 1.3; padding: 0; border-bottom: 1px solid #AAAAAA;</source>
=== Heading === <h3> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 1.17em; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
==== Heading ==== <h4> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
===== Heading ===== <h5> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>
====== Heading ====== <h6> <source lang="css">color: #45C3B8; background: none; overflow: hidden; page-break-after: avoid; font-size: 100%; font-weight: bold; margin-top: 0.3em; margin-bottom: 0; line-height: 1.6; padding-top: 0.5em; padding-bottom: 0;</source>

Templates: {{fake heading}} for use in documentation

p

<p>...</p> tag places content into a separate paragraph.

Markup Renders as
<p>HyperText Markup Language</p><p>HyperText Markup Language</p> 

HyperText Markup Language

HyperText Markup Language

Wikimarkup: Separate paragraphs by a single blank line.

Markup Renders as
HyperText Markup Language

HyperText Markup Language 

HyperText Markup Language

HyperText Markup Language

br

<br> or <br /> inserts a line break. Both versions of the break are supported by HTML5. </br> is invalid.

Markup Renders as
HyperText<br>Markup Language 
HyperText
Markup Language

Templates:

  • {{crlf2}} adds a true carriage return and line feed.
  • {{clear}} adds a break with styling to clear floating elements.
  • {{plainlist}} creates an unbulleted list.

hr

<hr> represents a paragraph-level thematic break and presents as a horizontal rule.

Markup Renders as
<hr> 

Wikimarkup: use ----

Markup Renders as
---- 


Templates: {{hr}}

comment

<!-->...</!--> formats the enclosed text as a hidden comment.

Markup Renders as
HyperText<!--Markup Language--> 
HyperText

Formatting

abbr

<abbr>...</abbr> creates a tooltip to define an abbreviation or acronym that is displayed on mouse-over.

Markup Renders as
<abbr title="HyperText Markup Language">HTML</abbr> 
HTML

Templates: {{abbr}}; supports Unicode display

b

<b>...</b> formats text stylistically offset from other text (bold) without conveying extra importance.

Markup Renders as
<b>HyperText Markup Language</b> 
HyperText Markup Language

Wikimarkup: Use ''' to open and close bold text.

Markup Renders as
'''HyperText Markup Language''' 
HyperText Markup Language

blockquote

<blockquote>...</blockquote> presents text in an offset block.

Markup Renders as
<blockquote>HyperText Markup Language</blockquote> 

HyperText Markup Language

Templates: {{quote}}; supports pre-formatted attribution and source parameters.

code

<code>...</code> formats a section of computer code. Styled with CSS through elements.css as a Courier monospaced slab serif typeface with border.

Markup Renders as
<code>HyperText Markup Language</code> 
HyperText Markup Language

Templates: {{code}} uses <syntaxhighlight>.

del

<del>...</del> formats deleted text.

Markup Renders as
<del>HyperText Markup Language</del> 
HyperText Markup Language

dfn

<dfn>...</dfn> is used for indicating a definition.

Markup Renders as
<dfn>Definition</dfn> 
Definition

em

<em>...</em> represents a span of text with emphatic stress.

Markup Renders as
<em>HyperText Markup Language</em> 
HyperText Markup Language

i

<i>...</i> represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is italic text.

Markup Renders as
<i>HyperText Markup Language</i> 
HyperText Markup Language

Wikimarkup: Use '' to open and close italic text.

Markup Renders as
''HyperText Markup Language'' 
HyperText Markup Language

kbd

<kbd>...</kbd> indicates user input such as keyboard input or voice commands.

Markup Renders as
Press <kbd>Enter</kbd> 
Press Enter

Templates:

  • {{key press}} renders illustrated keys and keystrokes.

mark

<mark>...</mark> represents a run of text in one document marked or highlighted for reference purposes, due to its relevance in another context. Marked text is formatted with a yellow background by default.

Markup Renders as
<mark>HyperText Markup Language</mark> 
HyperText Markup Language

<mark style="background:lightblue">HyperText Markup Language</mark> 
HyperText Markup Language

pre

<pre>...</pre> element represents a block of preformatted text. In MediaWiki, <pre>...</pre> is actually a parser tag and not HTML, but the function is the same.

Markup Renders as
<pre>HyperText Markup Language</pre> 
HyperText Markup Language

HTML entities

<pre>...</pre> parses HTML entities. If you want to escape this, replace & with &amp;.

Markup Renders as
<pre>&amp;</pre> 
&

<pre>&lt;</pre> 
<

<pre>&amp;amp;</pre> 
&amp;

<pre>&amp;lt;</pre> 
&lt;

q

<q>...</q> is used to mark a short quotation.

Markup Renders as
<q>HyperText Markup Language</q> 
HyperText Markup Language


s

<s>...</s> is used to indicate content that is no longer accurate or relevant and that has been struck from the page. It is not appropriate when indicating document edits; to mark a span of text as having been removed from a document, use <del>.

Markup Renders as
<s>HyperText Markup Language</s> 
HyperText Markup Language

small

<small>...</small> format small text.

Markup Renders as
<small>HyperText Markup Language</small> 
HyperText Markup Language

Templates:

  • {{small}} uses <small style="font-size:85%;">. {{small}} is recommended over <small> since not all browsers render small text the same.

strong

<strong>...</strong> formats a span of text with strong importance.

Markup Renders as
<strong>HyperText Markup Language</strong> 
HyperText Markup Language

sub

<sub>...</sub> formats a span of text as a subscript.

Markup Renders as
HyperText <sub>Markup Language</sub> 
HyperText Markup Language

sup

<sup>...</sup> formats a span of text as a superscript.

Markup Renders as
HyperText <sup>Markup Language</sup> 
HyperText Markup Language

time

<time>...</time> defines either a time (24 hour clock), or a date in the Gregorian calendar, optionally with a time and a time-zone offset.

Markup Renders as
<time>10:00</time> 

Attributes: datetime

Support: Not supported by Internet Explorer 8 and below.

u

<u>...</u> represents a span of text offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is underlining; for example, a span of text in Chinese that is a proper name (a Chinese proper name mark), or span of text that is known to be misspelled.

Markup Renders as
<u>HyperText Markup Language</u> 
HyperText Markup Language

Lists

Further information: Help:List

Do not leave blank lines between items in a list unless there is a reason to do so, since this causes the MediaWiki software to interpret each item as beginning a new list.

dl, dt, dd

<dl>...</dl>, <dt>...</dt> and <dd>...</dd> are used to create a description list (formerly definition list) with terms and descriptions. Terms are displayed in bold and descriptions are indented. Each term must include one or more descriptions.

Markup Renders as
<dl>
<dt>Term</dt>
<dd>Definition 1</dd>
<dd>Definition 2</dd>
<dd>Definition 3</dd>
<dd>Definition 4</dd>
</dl> 
Term
Definition 1
Definition 2
Definition 3
Definition 4

Wikimarkup: <dt> is created using ; while automatically enclosed in <dl>...</dl>. <dd> is created using : for each value. For a single or first value the : can be placed on the same line after ; where subsequent values must be placed on separate lines.

Markup Renders as
; Term
: Definition 1
: Definition 2
: Definition 3
: Definition 4 
Term
Definition 1
Definition 2
Definition 3
Definition 4


ol, ul, li

<ol>...</ol> represents an ordered list; <ul>...</ul> represents an unordered list; <li>...</li> represents a list item within either type of list.

Markup Renders as
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ol> 
  1. Item 1
  2. Item 2
  3. Item 3
  4. Item 4

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul> 
  • Item 1
  • Item 2
  • Item 3
  • Item 4

Wikimarkup: use * for items in an unordered list and # for ordered lists.

Markup Renders as
# Item 1
# Item 2
# Item 3
# Item 4 

  1. Item 1
  2. Item 2
  3. Item 3
  4. Item 4

* Item 1
* Item 2
* Item 3
* Item 4 

  • Item 1
  • Item 2
  • Item 3
  • Item 4

Templates: for a variety of specialized uses, see Category:List formatting and function templates.

Containers

div

<div>...</div> is a generic container for flow content that displays as a block element.

Markup Renders as
HyperText <div>Markup</div> Language 
HyperText
Markup
Language

span

<span>...</span> is a container for flow content that displays as an inline element.

Markup Renders as
HyperText <span>Markup</span> Language 
HyperText Markup Language

Tables

Further information: Help:Table

table, td, tr

<table>...</table> defines a table.

<tr>...</tr> defines a table row.

<td>...</td> defines a data cell with contents that may include text, links, images, lists, forms, other tables, etc.

Markup Renders as
<table border=1>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table> 
data data

Attributes:

  • <table>:
  • <td>: colspan, headers, rowspan
  • Use style</style> with CSS to achieve the following.
    Allowed but not recommended: border="" and border="1"
    Allowed but obsolete: abbr, align, axis, bgcolor, scope, height, nowrap, valign, width,border (with a non-empty value different from "1"), cellpadding, cellspacing, frame, rules, summary

th

<th>...</th> defines a table header; styled as centered and bold.

Markup Renders as
<table border="1">
<tr>
<th>Header</th>
<th>Header</th>
</tr>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table> 
Header Header
data data

Attributes:

  • <th>: colspan, headers, rowspan, scope
    Allowed but obsolete: abbr, align, axis, bgcolor, scope, height, nowrap, valign, width

caption

<caption>...</caption> adds a caption to a table.

Markup Renders as
<table border=1>
<caption>Caption</caption>
<tr>
<td>data</td>
<td>data</td>
</tr>
</table> 
Caption
data data

Attributes:

  • <caption>:
    Allowed but obsolete: align

thead, tfoot, tbody

<thead>, <tfoot> and <tbody> are not supported, but are automatically generated when the page is rendered.

Obsolete elements

These elements are now obsolete in HTML5, but still supported by browsers. These tags either have an alternate tag or a template that replaces their function with CSS. See HTML5 for more details on obsolete HTML parts and their replacements.

big

<big>...</big> (obsolete) formats text in a larger font size.

Templates: {{big}} uses CSS.

center

For centering tables, see Help:Table#Centering tables.

<center>...</center> (obsolete) is used to center text elements.

Templates: {{center}} uses CSS.

font

<font>...</font> (obsolete) is used to set the font size, font face and color of text.

rb

<rb>...</rb> (obsolete) Used to mark base text in a ruby annotation

strike

<strike>...</strike> (obsolete) formats strike-through characters; use <s> instead.

tt

<tt>...</tt> (obsolete) formats text in a fixed-width font. Use <code>, <kbd> or <samp> instead.

Unsupported elements

These elements are not supported, but have equivalent wiki markup. Attempting to use any element not whitelisted by sanitizer.php will result in the markup showing as plain text.

a

Further information: Help:Wiki markup#Links and URLs

<a> is used to create links. Use the [[ ]] wikimarkup for internal links and [ ] for external links.

input

Further information: mw:Extension:InputBox

<input> is used to create forms. The <inputbox> extension tag is used to create a text box with a button.

Parser and extension tags

Parser tags
<gallery>, <includeonly>, <noinclude>, <nowiki>, <onlyinclude>, <pre>
Extension tags
<categorytree>, <charinsert>, <graph>, <imagemap>, <indicator>, <inputbox>, <section>, <syntaxhighlight> (alias <source>), <templatedata>, <timeline>


See also

External links

Template:Help navigation