![]() | This help page is a how-to guide. It explains concepts or processes used by the Wikipedia community. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus. |
HTML |
---|
![]() |
HTML and variants |
HTML elements and attributes |
Editing |
Character encodings and language |
Document and browser models |
Client-side scripting and APIs |
Graphics and Web3D technology |
Comparisons |
The MediaWiki software, which drives Wikipedia, allows the use of a subset of HTML5 elements, or tags and their attributes, for presentation formatting.[1] But most HTML can be included by using equivalent wiki markup or templates; these are generally preferred within articles, as they are sometimes simpler for most editors and less intrusive in the editing window; but 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, and so are really wiki markup. HTML in pages can be checked for HTML5 compliance by using validation. Some elements and attributes are supported by MediaWiki and browsers, but have been deprecated by HTML5, and therefore should no longer be used.
Tutorials
This help page gives only an overview of allowed markup. For further assistance and detailed specifications:
- HTML5 Introduction at developer.mozilla.org
- HTML5 Introduction at w3schools.com
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[1]:
class
: one or more classifications to which the element belongs. See Wikipedia:Catalogue of CSS classes.dir
: text direction—"ltr"
(left-to-right),"rtl"
(right-to-left) or"auto"
.id
: unique identifier for the element.lang
: primary language for the contents of the element per BCP 47. The MediaWiki software automatically adds thexml:lang
attribute wheneverlang
is defined, butxml:lang
will no longer be passed when included as a separate attribute.style
: applies CSS styling to the contents of the element.title
: advisory information associated with the element.
HTML5 microdata attributes apply to all tags:[2]
- 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.
|
|
|
|
All the Studios 1&2 30€ (2person)
++apartment 3+4 (Suitable for 4 persons+and a Child max 5) 65€
++penthouse Apartment A5 (sea view) € 75(Suitable for 4 persons)
parking 5€(garage)our Range .
Information about booking <img alt="cheeky" height="20" src="https://de.hpage.com/interface/assets/3rdparty/ckeditor/plugins/smiley/images/tounge_smile.gif" title="cheeky" width="20" />
To the booking portal+click on the Image !!
⇓
<a href="https://www.booking.com/hotel/hr/apartmani-mustapic-makarska.en-gb.html?label=gen173nr-1DCAsoZUIbYXBhcnRtYW5pLW11c3RhcGljLW1ha2Fyc2thSC5YBGg7iAEBmAEuwgEKd2luZG93cyAxMMgBDNgBA-gBAZICAXmoAgM;sid=0d628984f8b4bb50e63bbc81c677d35a;dist=0&sb_price_type=total&type=total&" style="color: #000000;" target="_blank"><img align="" alt="Apartmani in Makarska Zagrebacka 80" height="150" src="http://file1.hpage.com/010130/69/bilder/005.jpg" style="padding: 0px; margin: 0px;" title="Click for booking" width="200" /></a>
Obsolete/deprecated elements
These elements are now obsolete and deprecated in HTML5, but still supported by browsers.[3] These tags either have an alternate tag or a template that replaces their function with CSS. See Wikipedia:HTML5 for more details on obsolete HTML parts and their replacements.
center
is used to center text elements.
<center>...</center>
(obsolete)
Templates: {{center}}
uses CSS.
font
is used to set the font size, font face and color of text.
<font>...</font>
(obsolete)
Templates: {{font}}
uses CSS.
rb
Used to mark base text in a ruby annotation
<rb>...</rb>
(obsolete)
strike
formats strike-through characters; use <strike>...</strike>
(obsolete)<s>
instead.
tt
formats text in a fixed-width font. Use <tt>...</tt>
(obsolete)<code>
, <kbd>
or <samp>
instead.
Templates: {{mono}}
uses CSS.
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
<a>
is used to create links. Use the [[ ]]
wikimarkup for internal links and [ ]
for external links.
input
<input>
is used to create forms. The <inputbox>
extension tag is used to create a text box with a button.
HTML Tidy
HTML Tidy is an outdated HTML4 library that is slated for removal. Tidy parses the MediaWiki output and cleans it up to increase the likelihood that valid HTML4 is rendered. For example, with Tidy enabled, <br>
, </br>
, <br/>
, <br.>
all rendered as <br />
. Tidy is not enabled for MediaWiki interface pages. Tidy was never perfect and has been known to introduce errors.
Exceptions
In some pages in the MediaWiki namespace, typically the short messages like button labels, HTML is not parsed, and tags will be exposed.
User and sitewide CSS and JavaScript pages are interpreted as if inside a <pre>
block. See Help:User style.
Validation
The MediaWiki software attempts to fix HTML errors, but it does not catch all of them. Where HTML is used, it is helpful to verify it with the W3C Markup Validation Service.
Parser and extension tags
For a machine-generated list, see Special:Version#mw-version-parser-extensiontags. It may include tags not documented here.
- Parser tags
<gallery>
,<includeonly>
,<noinclude>
,<nowiki>
,<onlyinclude>
,<pre>
- Extension tags
<categorytree>
,<charinsert>
,<chem>
(alias<ce>
),<graph>
,<hiero>
,<imagemap>
,<indicator>
,<inputbox>
,<mapframe>
,<maplink>
,<math>
,<math chem>
,<poem>
,<ref>
,<references>
,<score>
,<section>
,<syntaxhighlight>
(alias<source>
),<templatedata>
,<templatestyles>
,<timeline>
See also
References
- ^ a b Allowable elements and attributes are defined in the
Sanitizer.php
module. - ^ "The microdata model". HTML Living Standard.
- ^ "HTML5: A vocabulary and associated APIs for HTML and XHTML: Obsolete Features". W3C. 31 July 2014.
External links
- HTML 4.01 specification: elements | attributes