Help:HTML in wikitext: Difference between revisions

Content deleted Content added
No edit summary
Tags: Mobile edit Mobile web edit
m Reverted edits by 39.8.45.194 (talk) to last version by EEng
Line 1:
{{Locutions pages header}}
{{Wikipedia how to|H:HTML|WP:HTML}}
{{Wiki markup}}
{{HTML}}
The MediaWiki software, which drives Wikipedia, allows the use of a subset of [[HTML5]] [[HTML element|elements]], or tags and their [[HTML attribute|attributes]], for presentation formatting.{{r|sanitizer}} But most HTML can be included by using equivalent [[Help:Wiki markup|wiki markup]] or [[Help:Template|templates]]; these are generally preferred within articles, as they are sometimes simpler for most editors and less intrusive in the editing window; but [[Wikipedia:Manual_of_Style#Keep_markup_simple|Wikipedia's Manual of Style]] recommends their use in certain cases. And HTML is useful outside of articles, for example for formatting within templates. 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|parser and extension tags]], and so are really wiki markup. HTML in pages can be checked for HTML5 compliance by using [[#Validation|validation]].
{{TOC limit|3}}
 
== Tutorials ==
This help page gives only an overview of allowed markup. For further assistance and detailed specifications:
* [https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Introduction_to_HTML5 HTML5 Introduction] at developer.mozilla.org
* [http://www.w3schools.com/html/html5_intro.asp HTML5 Introduction] at w3schools.com
 
== Attributes ==
[[HTML attribute]]s provide additional information about an element and are always specified in the start tag. They are formatted as a name/value pair like <code>name="value"</code>.
 
Global attributes apply to all tags. Attributes not listed here are not allowed by MediaWiki{{r|sanitizer}}:
* <code>class</code>: one or more classifications to which the element belongs. See [[Wikipedia:Catalogue of CSS classes]].
* <code>dir</code>: text direction— "<code>ltr</code>" (left-to-right), "<code>rtl</code>" (right-to-left) or "<code>auto</code>".
* <code>id</code>: unique identifier for the element.
* <code>lang</code>: primary language for the contents of the element per [[BCP 47]]. The MediaWiki software automatically adds the <code>xml:lang</code> attribute whenever <code>lang</code> is defined, but <code>xml:lang</code> will no longer be passed when included as a separate attribute.
* <code>style</code>: applies CSS styling to the contents of the element.
* <code>title</code>: advisory information associated with the element.
 
HTML5 microdata attributes apply to all tags:{{r|html5microdata}}
* Any attribute beginning with <code>data-</code>
* <code>itemid</code>
* <code>itemprop</code>
* <code>itemref</code>
* <code>itemscope</code>
* <code>itemtype</code>
 
<!-- As of 10 January 2013, $wgAllowRdfaAttributes is not enabled, thus the attributes will be stripped
[[RDFa]] attributes:{{r|rdfa}}
* <code>about</code>
* <code>property</code>
* <code>resource</code>
* <code>datatype</code>
* <code>typeof</code>
-->
Other tags such as {{tag|table|o}} support specific attributes – these are listed in the appropriate section.
 
{{markup
|<nowiki>This is <span style="color:red;">red</span> text.</nowiki>
|2=This is <span style="color:red;">red</span> 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 element]]s are supported by the MediaWiki software. This section gives a brief overview of the HTML element, an example, relevant wikimarkup and templates.