Help:HTML in wikitext: Difference between revisions

Content deleted Content added
No edit summary
 
(25 intermediate revisions by the same user not shown)
Line 1:
<noinclude>{{pp-semi-indef|small=yes}}
</noinclude>{{Redirect|Wikipedia:WP:HTML|general information about the default markup language on Wikipedia|Wikipedia:HTML 5}}
{{Locutions pages header}}
{{Wikipedia how to}}
{{Wiki markup}}
{{HTMLCommons Import}}
 
The MediaWiki software, which drives Wikipedia, allows the use of a subset of [[Wikipedia:HTML 5]] [[Wikipedia:HTML element|elements]], or tags and their [[Wikipedia:HTML attribute|attributes]], for presentation formatting.{{r|sanitizer}} But most HTML can be included by using equivalent [[Wikipedia:Help:Wiki markup|wiki markup]] or [[Wikipedia: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. (See [[Help:Wikitext]] for wiki equivalents to HTML tags not otherwise discussed below.) And HTML is useful outside of articles, for example for formatting within templates. For help with Cascading Style Sheet use within Wikipedia see [[Wikipedia: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]]. Some elements and attributes are supported by MediaWiki and browsers, but have been [[Wikipedia:HTML 5|deprecated by HTML 5]], and therefore should no longer be used.
Line 16 ⟶ 17:
 
== Attributes ==
[[wikipedia:HTML attribute|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:Wikipedia:Catalogue of CSS classes|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 [[Wikipedia:BCP 47|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.
Line 35 ⟶ 36:
 
<!-- As of 10 January 2013, $wgAllowRdfaAttributes is not enabled, thus the attributes will be stripped
[[wikipedia:RDFa|]] attributes:{{r|rdfa}}
* <code>about</code>
* <code>property</code>
Line 59 ⟶ 60:
 
== Elements ==
These [[Wikipedia:HTML element|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.
 
=== Basic ===
 
==== h1, h2, h3, h4, h5, h6 ====
{{see|Wikipedia:Help:Section|Wikipedia:MOS:HEAD}}
The {{tag|h1}} through {{tag|h6}} tags are headings for the sections with which they are associated. {{tag|h1|o}} is used for the article title. Headings are [[Wikipedia:Help:Cascading Style Sheets#Wiki headings|styled through CSS]] and added to the page's [[Wikipedia:Help:table of contents|table of contents]].
 
{{markup
Line 133 ⟶ 134:
 
==== br ====
{{see|Wikipedia:Help:Line-break handling#&lt;br />|Wikipedia:Don't use line breaks}}
{{tag|br|o}} or {{tag|br|s}} inserts a line break. Both versions of the break are supported by HTML5. Using {{tag|br|o}} without the <code>/</code> breaks [[Wikipedia:Syntax highlighting#Syntax highlighting of wiki-code for editors|syntax highlighting]], so should be avoided. {{tag|br|c}} is invalid.
 
Line 148 ⟶ 149:
 
==== hr ====
{{see|Wikipedia:WP:LINE}}
{{tag|hr|o}} or {{tag|hr|s}} represents a paragraph-level thematic break and presents as a horizontal rule.
 
Line 166 ⟶ 167:
 
==== Comments ====
{{see|Wikipedia:WP:COMMENT}}
{{tag|!--}} formats the enclosed text as a hidden comment.
 
Line 199 ⟶ 200:
 
==== b ====
{{see|Wikipedia:MOS:BOLD}}
{{tag|b}} formats text stylistically offset from other text (bold) without conveying extra importance.
 
Line 243 ⟶ 244:
 
==== blockquote ====
{{see|Wikipedia:MOS:QUOTE}}
{{tag|blockquote}} presents text in an offset block.
 
Line 264 ⟶ 265:
 
==== code ====
{{tag|code}} formats a section of computer code. Styled with [[Wikipedia:Cascading Style Sheets|CSS]] through {{elements.css}} as a monospaced slab serif typeface with border.
 
{{markup
Line 304 ⟶ 305:
 
==== em ====
{{see|Wikipedia:MOS:ITALIC}}
{{tag|em}} represents a span of text with emphatic stress (i.e. semantic emphasis). In most browsers, it renders as italic.
 
Line 315 ⟶ 316:
 
==== i ====
{{see|Wikipedia:MOS:ITALIC}}
{{tag|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.
 
Line 330 ⟶ 331:
 
==== ins ====
{{tag|ins}} indicates a range of text that has been added. Styled as underlined text. Used on talk pages to indicate refactored text; see [[Wikipedia:WP:REDACT]].
 
{{markup
Line 375 ⟶ 376:
===== HTML entities =====
 
{{tag|pre|o}} parses [[Wikipedia:Character encodings in HTML|HTML entities]]. If you want to escape this, replace <code>&</code> with <code>&amp;amp;</code>, or use {{xtag|source|params = lang="text"}} instead.
 
{{markup
Line 416 ⟶ 417:
}}
 
[[Wikipedia:MOS:QUOTATIONS]] says Wikipedia should instead use "", {{tl|quote}}, or <nowiki><blockquote></nowiki>.
 
==== rp, rt, ruby ====
 
{{see|Ruby character}}
 
{{tag|ruby}} marks spans of phrasing content with ruby annotations.
 
{{tag|rt}} marks the ruby text component of a ruby annotation; the ruby text shows in a reduced size over top of the normal characters.
 
{{tag|rp}} is used to provide parentheses around a ruby text component of a ruby annotation, to be shown by user agents that don’t support ruby annotations.
 
Browsers that do not support ruby characters will show the ruby text in normal size, enclosed in parentheses and after the normal content.
 
{{markup
|<nowiki><ruby>
東<rp>(</rp><rt>とう</rt><rp>)</rp>
京<rp>(</rp><rt>きょう</rt><rp>)</rp>
</ruby></nowiki>
|<ruby>
東<rp>(</rp><rt>とう</rt><rp>)</rp>
京<rp>(</rp><rt>きょう</rt><rp>)</rp>
</ruby>
}}
 
Templates:
* {{tlx|ruby}}
* {{tlx|ruby-ja}} for Japanese
* {{tlx|Ruby-zh-p}} for Chinese pinyin
* {{tlx|Ruby-zh-b}} for Chinese bopomofo
 
==== s ====
Line 468 ⟶ 440:
 
==== small ====
{{see|Wikipedia:WP:FONTSIZE}}
{{tag|small}} format small text.
 
Line 480 ⟶ 452:
 
==== strong ====
{{tag|strong}} formats a span of text with strong importance or unusual emphasis; in most browsers it renders as boldface. This should generally not be used in Wikipedia articles, per [[Wikipedia:WP:Neutral point of view]] policy. See [[Wikipedia:MOS:BOLD]] on use of this element and other boldfacing. Most semantic emphasis, including in quoted material, should be rendered with the {{tag|em|o}} element.
 
{{markup
Line 490 ⟶ 462:
 
==== sub ====
{{see|Wikipedia:WP:SUBSCRIPT}}
{{tag|sub}} formats a span of text as a subscript.
 
Line 510 ⟶ 482:
 
==== sup ====
{{see|Wikipedia:WP:SUPSCRIPT}}
{{tag|sup}} formats a span of text as a superscript.
 
Line 540 ⟶ 512:
 
==== u ====
{{see|Wikipedia:MOS:BADEMPHASIS|Wikipedia:MOS:QUOTE}}
{{tag|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.
 
Line 551 ⟶ 523:
 
==== var ====
{{see|Wikipedia:MOS:ITALIC}}
{{tag|var}} formats text in italics to indicate a variable in a mathematical expression or programming context, or placeholder text that the reader is meant to mentally replace with some other literal value.
 
Line 570 ⟶ 542:
 
==== wbr ====
{{see|Wikipedia:Help:Line-break handling#&lt;wbr /&gt; and soft hyphens}}
{{tag|wbr|o}} is a word break opportunity; that is, it specifies where it would be OK to add a line-break where a word is too long, or it is perceived that the browser will break a line at the wrong place.
 
Line 584 ⟶ 556:
 
=== Lists ===
{{see|Help:List|Wikipedia:MOS: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.
Line 660 ⟶ 632:
 
==== div ====
{{see|Wikipedia:Span and div}}
{{tag|div}} is a generic container for flow content that displays as a block element.
 
Line 669 ⟶ 641:
 
==== span ====
{{see|Wikipedia:Span and div}}
{{tag|span}} is a container for flow content that displays as an inline element.
 
Line 678 ⟶ 650:
 
=== Tables ===
{{see|Help:Table|Wikipedia:MOS:TABLES}}
 
==== table, td, tr ====
Line 800 ⟶ 772:
=== a ===
{{details|Help:Wiki markup#Links and URLs}}
{{tag|a|o}} is used to create links. Use the <code><nowiki>[[ ]]</nowiki></code> wikimarkup for internal/intrawiki links and [[Wikipedia:interwiki links|interwiki links]], and <code><nowiki>[ ]</nowiki></code> for external links.
 
=== input ===
{{details|mwmediawikiwiki:Extension:InputBox}}
{{tag|input|o}} is used to create [[Wikipedia:Form (HTML)|forms]]. The {{xtag|inputbox}} extension tag is used to create a text box with a button.
 
== HTML Tidy ==
[[Wikipedia:HTML Tidy]] is an outdated HTML4 library that is [[:mw:Parsing/Replacing Tidy|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, {{tag|br|o}}, {{tag|br|c}}, {{tag|br/|o}}, {{tag|br.|o}} all rendered as {{tag|br|s}}. Tidy is not enabled for [[Wikipedia:Help:MediaWiki namespace|MediaWiki interface pages]]. Tidy was never perfect and has been known to introduce errors.
 
== Exceptions ==
In some pages in the [[Wikipedia:Help:MediaWiki namespace|MediaWiki namespace]], typically the short messages like button labels, HTML is not parsed, and tags will be exposed.
 
User and sitewide [[Wikipedia:CSS]] and [[Wikipedia:JavaScript]] pages are interpreted as if inside a {{tag|pre|o}} block. See [[Wikipedia:Help:User style|Help:User style]].
 
== Validation ==
{{Main|Wikipedia:Help:Markup 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 [[Wikipedia:W3C Markup Validation Service|W3C Markup Validation Service]].
 
== Parser and extension tags ==
{{shortcut|Help:Extension tag|Help:Parser tag}}
{{#section:Template:Xtag/doc|xtag}}
 
Line 836 ⟶ 807:
* HTML 4.01 specification: [http://www.w3.org/TR/html401/index/elements.html elements] | [http://www.w3.org/TR/html401/index/attributes.html attributes]
* HTML 5.2 specification: [//www.w3.org/TR/html5/fullindex.html#index-elements elements] | [//www.w3.org/TR/html5/fullindex.html#attributes-table attributes]
 
{{Help navigation}}
{{Wikipedia technical help|collapsed}}
 
[[Category:Wikipedia editor help]]