Cannabis Ruderalis

Content deleted Content added
Walexyyy (talk | contribs)
No edit summary
Fluffernutter (talk | contribs)
m Reverted edits by Walexyyy (talk) unexplained removal of content (HG)
Line 1: Line 1:
{{Wiki markup}}
== 1PLUSALL ==
{{shortcut|H:HTML|WP:HTML}}
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 a link to a particular element of a table.


==Permitted HTML==
Founded - Abuja, Nigeria[1](2011)
The following [[HTML element]]s are currently permitted:
Founder - Group of Nigeria University Students
{{Colbegin|2}}
Headquarters - Abuja, Nigeria.
; [[HTML element#General|&lt;abbr&gt;]] : An abbreviation (e.g., <abbr title="abbreviation">Abbr.</abbr>, <abbr title="Hypertext Markup Language">HTML</abbr>)
Area served - Worldwide
; [[HTML element#Presentation|&lt;b&gt;]] : Text <b>stylistically offset</b> from other text without conveying extra importance
Website - 1plusall.com
; [[HTML element#Presentation|&lt;big&gt;]] : Indicates representation in a <big>larger</big> font size
Type of site - Social networking service
; [[HTML element#Other block elements|&lt;blockquote&gt;]] : A section of quoted material,<blockquote>usually presented as an indented block,</blockquote> typically for long quotes
Advertising - Banner ads, referral marketing
; [[HTML element#Other inline elements|&lt;br&gt;]] : A line break<br/>in the middle of text such as poetry or addresses
Registration - Required
; [[HTML element#Tables|&lt;caption&gt;]] : <table style="width:100%" border=1><caption>A table caption</caption><tr><td>&nbsp;<td>&nbsp;</tr></table>
Available in - Multilingual
; [[HTML element#Other block elements|&lt;center&gt;]] (deprecated) : <center>Indicates presentation as a block-level center-aligned division</center>
Launched - July 19, 2011
; [[HTML element#Other inline elements|&lt;cite&gt;]] : Title of a work (e.g., <cite>{{PAGENAME}}</cite>)
; [[HTML element#Computer phrase elements|&lt;code&gt;]] : <code>A fragment of computer code</code>
; [[HTML element#Lists|&lt;dd&gt;]] : <dl><dd>A value</dd><dd>in a <nowiki><dl></nowiki>-marked association list</dd></dl>
; [[HTML element#Other block elements|&lt;del&gt;]] : Indicates a <del>deletion</del>
; [[HTML element#General|&lt;dfn&gt;]] : Marks a <dfn title="defined term">defined term</dfn>: a term that is defined in the nearby text.
; [[HTML element#Other block elements|&lt;div&gt;]] : <div>A division of text, usually presented as a block</div>
; [[HTML element#Lists|&lt;dl&gt;]] : <dl>An association list of names corresponding to values (e.g., terms and definitions, or properties and data)</dl>
; [[HTML element#Lists|&lt;dt&gt;]] : <dl><dt>A name</dt><dt>in a <nowiki><dl></nowiki>-marked association list</dd></dl>
; [[HTML element#General|&lt;em&gt;]] : A tag for stressing <em>emphasis</em>
; [[HTML element#Presentation|&lt;font&gt;]] (deprecated) : Indicates presentation with a <font color="green" size="-1" face="Courier">particular font color, typeface and/or size.</font>
; [[HTML element#Basic text|&lt;h1&gt;]] - [[HTML element#Basic text|&lt;h6&gt;]] : <h3>Section headings at different levels.</h3>
; [[HTML element#Other block elements|&lt;hr&gt;]] : A paragraph-level thematic break such as a transition to a different topic<hr/>Usually represented by a horizontal line.
; [[HTML element#Presentation|&lt;i&gt;]] : Text which is represented in <i>an alternate voice or mood</i>, usually represented by italics
; [[HTML element#Other block elements|&lt;ins&gt;]] : Indicates an <ins>insertion</ins>
; [[HTML element#Computer phrase elements|&lt;kbd&gt;]] : Indicates <kbd>text to be entered by the user.</kbd>
; [[HTML element#Lists|&lt;li&gt;]] : <li>A list item in ordered (ol)</li><li>or unordered (ul) lists</li>
; [[HTML element#Lists|&lt;ol&gt;]] :<ol><li>An ordered...</li><li>(enumerated) list</li></ol>
; [[HTML element#Basic text|&lt;p&gt;]] : Indicates a <p>paragraph or paragraph break.</p> (Paragraphs are usually indicated by [[Help:Wiki markup|Wiki markup]].)
; [[HTML element#Other block elements|&lt;pre&gt;]] : Represents a block of <pre>pre-formatted text</pre>
; [[Ruby character#Ruby markup|&lt;rb&gt;]] (deprecated) : formerly used to mark base text in a ruby annotation.
; [[Ruby character#Ruby markup|&lt;rp&gt;]] : Marks Ruby parentheses, an alternative for Ruby annotation: <ruby style="font-size:1.2em;">汉<rp>(</rp><rt>hàn</rt><rp>)</rp>字<rp>(</rp><rt>zì</rt><rp>)</rp></ruby> may be rendered as 汉 (hàn) 字 (zì)
; [[Ruby character#Ruby markup|&lt;rt&gt;]] : Marks a <ruby style="font-size:1.2em;">汉<rt>Ruby&nbsp;</rt>字<rt>annotation</rt></ruby>
; [[Ruby character#Ruby markup|&lt;ruby&gt;]] : A Ruby annotation: <ruby style="font-size:1.2em;">汉<rt>hàn</rt>字<rt>zì </rt></ruby>
; [[HTML element#Computer phrase elements|&lt;samp&gt;]] : Represents a <samp>sample output</samp>, such as from a program or script.
; [[HTML element#Presentation|&lt;s&gt; or &lt;strike&gt;]] (the latter deprecated) : Indicates text that is <s>no longer valid or relevant</s>
; [[HTML element#Presentation|&lt;small&gt;]] : Indicates <small>fine print</small> such as legal disclaimers in advertising
; [[HTML element#Span|&lt;span&gt;]] : <span>A division of text, usually presented inline with surrounding text</span>
; [[HTML element#General|&lt;strong&gt;]] : Stresses <strong>strong importance</strong>, usually presented in bold
; [[HTML element#Other inline elements|&lt;sub&gt;]] : Indicates a<sub>subscript</sub>
; [[HTML element#Other inline elements|&lt;sup&gt;]] : Indicates a<sup>superscript</sup>
; [[HTML element#Tables|&lt;table&gt;]] : <table>Identifies a table</table>
; [[HTML element#Tables|&lt;td&gt;]] : <table><td>A table data cell</td></table>
; [[HTML element#Tables|&lt;th&gt;]] : <table><th>A table header cell; contents are conventionally displayed bold and centered</th></table>
; [[HTML element#Tables|&lt;tr&gt;]] : <table><tr>Contains a row of cells in a table</tr></table>
; [[HTML element#Presentation|&lt;tt&gt;]] (deprecated): Indicates presentation in a <tt>fixed-width font</tt>
; [[HTML element#Presentation|&lt;u&gt;]] : Indicates a <u>non-textual annotation</u>, typically represented as underlining
; [[HTML element#Lists|&lt;ul&gt;]]
:<ul><li>An unordered...</li><li>(bulleted) list</li></ul>
; [[HTML element#Computer phrase elements|&lt;var&gt;]] : Indicates a <var>variable</var>
; [[HTML element#Comments|&lt;!-- ... --&gt;]] (will be stripped during processing) : <nowiki><!--Non-visible comment--></nowiki>
{{Colend}}


==Anchors==
1plusall is a social networking website launched in July 2011, operated and privately owned by 1plusall. Users may create a personal profile, add other users as friends, and exchange messages, including automatic notifications when they update their profile. 1plusall users must register before using the site. Additionally, users may join common-interest user networks, groups and other characteristics. The name of the service stems from what the site tends to offer. 1plusall allow users who declare themselves to be at least 13 years old to become registered users of the website.
HTML tags allow an <code>id</code> attribute that can be referenced in one's [[Help:User style|user style]] CSS, and allows the element to be used as link target.
1plusall was founded by a group of Nigerian University students.
1plusall is the first and only social networking website from Africa.
History
The idea of 1plusall was born after students of University of Abuja and the Federal University of Technology Minna met to discuss how to connect students of higher institutions in Nigeria. The idea was being realized but along the line, this idea evolved to building a social network not just to link Nigerian students together but also with the outside world in general.
Membership is restricted to people under the age of 13.
1plusall launched a mobile version on the same day as the PC version and does not require an invitation to join but requires a valid e-mail address.
Traffic to 1plusall has been steadily increasing since it was launched on July 19 2011.
At inception, 1plusall has a very low clickthrough rate (CTR) for advertisements than most websites. Explanations for 1plusall's low CTR include the fact that users use ad blocking software to hide advertisements, users ignores advertising messages.


However, the anchor element <code>a</code> is not allowed, so the wikitext
Website
<code><nowiki><a href="http://meta.wikimedia.org/">Main Page</a></nowiki></code>
Users can create profiles with photos, lists of personal interests, contact information, and other personal information. Users can communicate with friends and other users through private or public messages and a chat feature. They can also create and join interest networks, groups and "like” pages, some of which are maintained by organizations as a means of advertising.
is treated like the wikitext
To allay concerns about privacy, 1plusall enables users to choose their own privacy settings and choose who can see specific parts of their profile. The website is free to users, and generates revenue from advertising, such as banner ads. 1plusall requires a user's name and profile picture (if applicable) to be accessible by everyone. Users can control who sees other information they have shared, as well as who can find them in searches, through their privacy settings.
<code><nowiki>&amp;lt;a href="http://meta.wikimedia.org/"&amp;gt;Main Page&amp;lt;/a&amp;gt;</nowiki></code>
1plusall does not allow HTML and Cascading Style Sheets, 1plusall allows only plain text. 1plusall has a number of features with which users may interact. They include the Wall, a space on every user's profile page that allows friends to post messages for the user to see; Photos, where users can upload albums and photos; Status, which allows users to inform their friends of their whereabouts and actions; News Feed was announced, which appears on every user's homepage and highlights information including profile changes, upcoming events, and birthdays of the user's friends. Depending on privacy settings, anyone who can see a user's profile can also view that user's Wall.
and is therefore displayed as
Some of the most popular applications on 1plusall are the Photos and Videos application, where users can upload videos, albums and photos. Facebook allows users to upload an unlimited number of photos and videos. Another popular feature in 1plusall is the option for users to linking up to five songs and play it with 1plusall media player on the site.
{{Quote|1=<a href="http://meta.wikimedia.org/">Main Page</a>}}
Privacy settings can be set for individual albums, limiting the groups of users that can see an album. For example, the privacy of an album can be set so that only the user's friends can see the album, while the privacy of another album can be set so that all 1plusall users can see it. Another feature of the Photos application is the ability to "tag" users in a photo. For instance, if a photo contains a user's friend, then the user can tag the friend in the photo. This sends a notification to the friend that they have been tagged, and provides them a link to see the photo.
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):
1plusall Diary is an audience captivating feature which allows users enter information into the e-diary & keep it safe without any fear of people finding and reading it.
<code><nowiki>[http://meta.wikimedia.org/ Main Page]</nowiki></code>
Also on 1plusall is the Gifts feature which allows users to send virtual gifts to their friends that appear on the recipient's profile. Gifts are free of charge to purchase, and a personalized message can be attached to each gift. Another feature is Marketplace, which lets users post free adverts on what they want to sell and what they want to buy.
displays as
{{Quote|[http://meta.wikimedia.org/ Main Page]}}


The following excerpt from [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Sanitizer.php?view=markup Sanitizer.php] additionally shows which attributes are allowed.
Privacy

1plusall takes privacy of its users very serious. They provide privacy settings to control the information they want to be available to the general public.
<source lang="php">
$htmlpairsStatic = array( # Tags that must be closed
'b', 'del', 'i', 'ins', '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', 'p', 'span', 'u', 'abbr'
);
$htmlsingle = array(
'br', 'hr', 'li', 'dt', 'dd'
);
$htmlsingleonly = array( # Elements that cannot have close tags
'br', 'hr'
);
$htmlnest = array( # Tags that can be nested--??
'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul',
'dl', 'font', 'big', 'small', 'sub', 'sup', 'span'
);
$tabletags = array( # Can only appear inside table, we will close them
'td', 'th', 'tr',
);
$htmllist = array( # Tags used by list
'ul','ol',
);
$listtags = array( # Tags that can appear in a list
'li',
);
</source>

== Tags ==

{{mlw|HTML element|Span|<code>'''&lt;span>'''</code>}} is a generic inline text container.

<code>'''&lt;font>'''</code> is a similar tag which is [[deprecation|deprecate]]d (should not be used) in favor of <nowiki><span></nowiki>.''

For example
<source lang=html4strict>
a <font color="red">red</font> word.
</source>
produces the same result as
<source lang=html4strict>
a <span style="color:red">red</span> word.
</source>

See also {{tim|font size demo}} 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, <strong><nowiki><strong></nowiki></strong> 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.

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 <nowiki><span></nowiki> as a link target===

The standard way of providing a named anchor as an invisible target (i.e. <code><a name="Foo"></code>) doesn't work (since all <code><a></code> tags are converted), and [http://www.w3.org/TR/html401/struct/links.html an alternative suggested by the W3C], <code><nowiki><hN id="Foo"></hN></nowiki></code>, produces an "[Edit]" link.

However, <code><nowiki><span id="Foo"/></nowiki></code> does produce a target that can be the destination of a link. (This is silently changed to <code><nowiki><span id="Foo"></span></nowiki></code>). This is the method used by the {{tl|anchor}} template. 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.

This technique can be used to produce immutable links from one article to a section of another, which continue to work even if the section name is changed by someone who does not realize that another article links there. For example, <code><nowiki><span id="immutable link from Article"/></nowiki></code>.

===<nowiki><div></nowiki>===
<code>'''&lt;div>'''</code> is a generic block container. Rules:
* <nowiki><div></nowiki> should be followed by a newline
* <nowiki></div></nowiki> should be preceded by a newline
*<nowiki></div></nowiki> followed by text on the same line, two newlines and text before <nowiki><div></nowiki> on the same line should be avoided (because the two newlines only produce a space)

===HTML comment===
Using {{tim|t}}:
*{{xpd|t}}
*"<code><nowiki>{{subst:xpd|t}}</nowiki>"</code> gives "&lt;!--t-->start-pqr-end", producing HTML code without the comment.
The "Remove comments" option of [[mw:Extension:ExpandTemplates|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.

Example:

Wikitext:
----
<pre>
{{#expr:<!--p-->3}}

{{#ifeq:<!--p-->3|3|1|0}}

{{#if:<!--p-->|1|0}}
</pre>
----
Result of normal expansion, and of ExpandTemplates with "Remove comments" on:
----
{{#expr:<!--p-->3}}

{{#ifeq:<!--p-->3|3|1|0}}

{{#if:<!--p-->|1|0}}
----
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 <nowiki>{{void|</nowiki>''comment''}}. 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 <nowiki>{{{{{subst1|}}}#expr:3*{{{1}}} {{{{{subst1|}}}void|</nowiki> multiply by 3 }}}}.

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. <nowiki>{{{ multiply by 3 |}}} or, to recognize the intention, use pseudo comment tags: {{{<!- multiply by 3 ->|}}}, or real ones, if the empty string is not used as parameter: {{{<!-- multiply by 3 -->|}}}</nowiki>.

See also {{tim|t comment}}.

== Attributes ==

Most tags can have a <tt>style</tt> attribute. For example
<source lang=html4strict>
<div style="font-size:80%">
This is <span style="color:red">red</span> text.
</div>
</source>
produces:
<blockquote style="border:1px dotted gray; padding-left:20px">
<div style="font-size:80%">
This is <span style="color:red">red</span> text.
</div>
</blockquote>

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

<source lang=html4strict>
<div class="infobox">Example infobox</div>
</source>

<div class="infobox">Example infobox</div>
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 [[:en:Template_talk:Link_FA#How_does_it_work.3F|how {Link FA} works]] in enwiki.

Classes are also widely used to create [[microformat]]s. See [[WP:UF|the microformats project]] for more information. Some [[Wikipedia:WikiProject Microformats/classes|class names are reserved]] for use in microformats.

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

<!--
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.
-->

== Tags with special effect ==
=== Pre ===
<nowiki><pre></nowiki> tags work as the combination of <nowiki><nowiki></nowiki> and the standard HTML <nowiki><pre></nowiki> 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,

<nowiki><pre>This word is <b>bold</b>.</pre>
This word is <b>bold</b>.</nowiki>
will render as

<pre>This word is <b>bold</b>.</pre>
This word is <b>bold</b>.

=== Comments ===
<b>HTML comments in the wikitext (<nowiki><!-- ... --></nowiki>) will not appear in the HTML code at all.</b>

=== Headers ===
Headers (<nowiki><h1>...<h6></nowiki>) will be treated in a similar way as wikicode headers:

<h6>sample header</h6>

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 <nowiki><pre></nowiki> block. From MW 1.11 this also goes for sitewide CSS/JS; in earlier versions, you have to manually add <tt><nowiki>/*<pre>*/</nowiki></tt> to the beginning and <tt><nowiki>/*</pre>*/</nowiki></tt> to the end of those pages to avoid strange rendering.

==Validation==
{{main|Help:Markup 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]].

==See also==
*[[Wikipedia:Span tags]]

== External links ==
* HTML 4.01 specification: [http://www.w3.org/TR/html401/index/elements.html elements] | [http://www.w3.org/TR/html401/index/attributes.html attributes]
* For customizing the handling of HTML in MediaWiki, see the HTML and Tidy sections in [[mw:Manual:Configuration settings]]
* Some extensions allow adding arbitrary HTML to a page, for example [[mw:Extension:AddHTML]], [[mw:Extension:SecureHTML]] and [[mw:Extension:Secure HTML]]; see [[mw:Manual:$wgRawHtml|$wgRawHtml]] for a more complete list
* Within the MediaWiki codebase, these HTML checks happen in [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/Sanitizer.php includes/Sanitizer.php]

[[Category:Editor handbook]]
[[Category:Wikipedia editor help]]

[[pl:Pomoc:Używanie kodu HTML]]
[[pt:Ajuda:HTML]]
[[sv:Wikipedia:Taggar]]
[[zh:Help:HTML]]

Revision as of 18:59, 22 July 2011

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 a link to a particular element of a table.

Permitted HTML

The following HTML elements are currently permitted:

<abbr>
An abbreviation (e.g., Abbr., HTML)
<b>
Text stylistically offset from other text without conveying extra importance
<big>
Indicates representation in a larger font size
<blockquote>
A section of quoted material,

usually presented as an indented block,

typically for long quotes
<br>
A line break
in the middle of text such as poetry or addresses
<caption>
A table caption
  
<center> (deprecated)
Indicates presentation as a block-level center-aligned division
<cite>
Title of a work (e.g., HTML in wikitext)
<code>
A fragment of computer code
<dd>
A value
in a <dl>-marked association list
<del>
Indicates a deletion
<dfn>
Marks a defined term: a term that is defined in the nearby text.
<div>
A division of text, usually presented as a block
<dl>
An association list of names corresponding to values (e.g., terms and definitions, or properties and data)
<dt>
A name
in a <dl>-marked association list
<em>
A tag for stressing emphasis
<font> (deprecated)
Indicates presentation with a particular font color, typeface and/or size.
<h1> - <h6>

Section headings at different levels.

<hr>
A paragraph-level thematic break such as a transition to a different topic
Usually represented by a horizontal line.
<i>
Text which is represented in an alternate voice or mood, usually represented by italics
<ins>
Indicates an insertion
<kbd>
Indicates text to be entered by the user.
<li>
  • A list item in ordered (ol)
  • or unordered (ul) lists
  • <ol>
    1. An ordered...
    2. (enumerated) list
    <p>
    Indicates a

    paragraph or paragraph break.

    (Paragraphs are usually indicated by Wiki markup.)
    <pre>
    Represents a block of
    pre-formatted text
    <rb> (deprecated)
    formerly used to mark base text in a ruby annotation.
    <rp>
    Marks Ruby parentheses, an alternative for Ruby annotation: (hàn)() may be rendered as 汉 (hàn) 字 (zì)
    <rt>
    Marks a Ruby annotation
    <ruby>
    A Ruby annotation: hàn
    <samp>
    Represents a sample output, such as from a program or script.
    <s> or <strike> (the latter deprecated)
    Indicates text that is no longer valid or relevant
    <small>
    Indicates fine print such as legal disclaimers in advertising
    <span>
    A division of text, usually presented inline with surrounding text
    <strong>
    Stresses strong importance, usually presented in bold
    <sub>
    Indicates asubscript
    <sup>
    Indicates asuperscript
    <table>
    Identifies a table
    <td>
    A table data cell
    <th>
    A table header cell; contents are conventionally displayed bold and centered
    <tr>
    Contains a row of cells in a table
    <tt> (deprecated)
    Indicates presentation in a fixed-width font
    <u>
    Indicates a non-textual annotation, typically represented as underlining
    <ul>
    • An unordered...
    • (bulleted) list
    <var>
    Indicates a variable
    <!-- ... --> (will be stripped during processing)
    <!--Non-visible comment-->

    Anchors

    HTML tags allow an id 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 a is not allowed, so the wikitext

    <a href="http://meta.wikimedia.org/">Main Page</a>
    

    is treated like the wikitext

    &lt;a href="http://meta.wikimedia.org/"&gt;Main Page&lt;/a&gt;
    

    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 (<a>) the wiki markup for external reference is required (enclosed in square brackets with the URL separated from the contents by a single space):

    [http://meta.wikimedia.org/ Main Page]
    

    displays as

    Main Page

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

    $htmlpairsStatic = array( # Tags that must be closed
        'b', 'del', 'i', 'ins', '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', 'p', 'span', 'u', 'abbr'
    );
    $htmlsingle = array(
        'br', 'hr', 'li', 'dt', 'dd'
    );
    $htmlsingleonly = array( # Elements that cannot have close tags
        'br', 'hr'
    );
    $htmlnest = array( # Tags that can be nested--??
        'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul',
        'dl', 'font', 'big', 'small', 'sub', 'sup', 'span'
    );
    $tabletags = array( # Can only appear inside table, we will close them
        'td', 'th', 'tr',
    );
    $htmllist = array( # Tags used by list
        'ul','ol',
    );
    $listtags = array( # Tags that can appear in a list
        'li',
    );
    

    Tags

    Template:Mlw is a generic inline text container.

    <font> is a similar tag which is deprecated (should not be used) in favor of <span>.

    For example

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

    produces the same result as

    a <span style="color:red">red</span> word.
    

    See also m:Template:font size demo (backlinks edit) and m:Help:Text color.

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

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

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

    However, <span id="Foo"/> does produce a target that can be the destination of a link. (This is silently changed to <span id="Foo"></span>). This is the method used by the {{anchor}} template. 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.

    This technique can be used to produce immutable links from one article to a section of another, which continue to work even if the section name is changed by someone who does not realize that another article links there. For example, <span id="immutable link from Article"/>.

    <div>

    <div> is a generic block container. Rules:

    • <div> should be followed by a newline
    • </div> should be preceded by a newline
    • </div> followed by text on the same line, two newlines and text before <div> on the same line should be avoided (because the two newlines only produce a space)

    HTML comment

    Using m:Template:t (backlinks edit):

    • Template:Xpd
    • "{{subst:xpd|t}}" gives "<!--t-->start-pqr-end", producing HTML code without the comment.

    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.

    Example:

    Wikitext:


    {{#expr:<!--p-->3}}
    
    {{#ifeq:<!--p-->3|3|1|0}}
    
    {{#if:<!--p-->|1|0}}
    

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


    3

    1

    0


    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 {{void|comment}}. 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 {{{{{subst1|}}}#expr:3*{{{1}}} {{{{{subst1|}}}void| multiply by 3 }}}}.

    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. {{{ multiply by 3 |}}} or, to recognize the intention, use pseudo comment tags: {{{<!- multiply by 3 ->|}}}, or real ones, if the empty string is not used as parameter: {{{<!-- multiply by 3 -->|}}}.

    See also m:Template:t comment (backlinks edit).

    Attributes

    Most tags can have a style attribute. For example

    <div style="font-size:80%">
    This is <span style="color:red">red</span> text.
    </div>
    

    produces:

    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

    <div class="infobox">Example infobox</div>
    
    Example infobox

    Produces the box which floats on the right because infobox class is already defined in local Mediawiki:Common.css.

    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 title, for example used in {{H:title}} template: note the hover box over "20000 ft"

    "a height of 6.1 km above sea level"


    Tags with special effect

    Pre

    <pre> tags work as the combination of <nowiki> and the standard HTML <pre> 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,

    <pre>This word is <b>bold</b>.</pre>
      This word is <b>bold</b>.
    

    will render as

    This word is <b>bold</b>.
    This word is bold.
    

    Comments

    HTML comments in the wikitext (<!-- ... -->) will not appear in the HTML code at all.

    Headers

    Headers (<h1>...<h6>) 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. <span id=abc> produces the HTML &lt;span id=abc&gt; rendered by the browser as <span id=abc>. 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 <pre> block. From MW 1.11 this also goes for sitewide CSS/JS; in earlier versions, you have to manually add /*<pre>*/ to the beginning and /*</pre>*/ 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.

    See also

    External links

    Leave a Reply