मदद:HTML in wikitext
ई लेख एगो हाउ-टु-गाइड (how-to guide) चाहे कइसे-कइल-जाय के बतावे वाला लेख हवे। ई विकिपीडिया के नीति आ दिशानिर्देश खातिर ना हवे; अगर कौनों नीति आ निर्देश संबंधी मुद्दा होखे त ओह बिसय से संबंधित नीति देखल जाय। |
The MediaWiki software allows use of a subset of HTML5 markup elements for presentation formatting.[1] Many HTML elements may also be included by equivalent wiki markup or templates which are simpler for most editors and less intrusive in the editing window. In normal practice, wiki markup or templates are preferred within articles, but HTML is quite useful for formatting within templates.
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
संपादन करीं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 thorough CSS.
Markup | Renders as |
---|---|
<h2>Heading</h2> <h3>Heading</h3> |
|
Wikimarkup: Headers formatted with wikimarkup add an [edit] link.
Tag | Wikimarkup | Style |
---|---|---|
<h1> |
=heading= |
font size 188%; bottom border |
<h2> |
==heading== |
font size 150%; bottom border |
<h3> |
====heading==== |
font size 132%; bold |
<h4> |
=====heading===== |
font size 116%; bold |
<h5> |
======heading====== |
font size 100%; bold |
<h6> |
========heading======== |
font size 80%; bold |
<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.
Markup | Renders as |
---|---|
HyperText<br>Markup Language |
HyperText |
Wikimarkup: two new lines will insert one break.
Templates:
- {{break}} adds multiple
<br />
. - {{crlf2}} adds adds a true carriage return and line feed.
- {{-}} adds a break with styling to clear floating elements.
hr
संपादन करीं<hr>
represents a paragraph-level thematic break and presents as a horizontal rule.
Markup | Renders as |
---|---|
<hr> |
|
Wikimarkup: use ----
Markup | Renders as |
---|---|
---- |
|
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 |
Support: not supported by IE6 or IE7.
Template: {{abbr}}; supports Unicode display
<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> |
|
Template: {{quote}}; supports pre-formatted attribution and source parameters. For other specialized quotation templates, see Category:Quotation templates.
cite
संपादन करीं<cite>...</cite>
contains the title of a work. This is a new definition in HTML5— in the previous XML implementation <cite>
was used to contain a citation or a reference to other sources.
Markup | Renders as |
---|---|
<cite>HyperText Markup Language</cite> |
HyperText Markup Language |
code
संपादन करीं<code>...</code>
formats a section of computer code. MediaWiki applies CSS styling to display <code>
in a monospace font.
Markup | Renders as |
---|---|
<code>HyperText Markup Language</code> |
|
Template: {{code}} uses <syntaxhighlight>
.
data
संपादन करीं<data>...</data>
formats a machine-readable version of contents defined by the value
attribute.
Markup | Renders as |
---|---|
<data value="978-0764502149">HTML for Dummies</data> |
HTML for Dummies |
del
संपादन करीं<del>...</del>
formats deleted text.
Markup | Renders as |
---|---|
<del>HyperText Markup Language</del> |
|
dfn
संपादन करीं<dfn>...</dfn>
is used for indicating a definition.
Markup | Renders as |
---|---|
<dfn>Definition</dfn> |
Definition |
Template: {{dfn}}
em
संपादन करीं<em>...</em>
represents a span of text with emphatic stress.
Markup | Renders as |
---|---|
<em>HyperText Markup Language</em> |
HyperText Markup Language |
Template: {{em}}
<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 |
ins
संपादन करीं<ins>...</ins>
indicates a range of text that has been added. Styled as underlined text. Used on talk pages to indicate refactored text; see WP:REDACT.
Markup | Renders as |
---|---|
<ins>HyperText Markup Language</ins> |
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:
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>
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>
parses HTML entities. If you want to escape this, replace &
with &
.
Markup | Renders as |
---|---|
<nowiki>&</nowiki> |
|
<nowiki><</nowiki> |
|
<nowiki>&amp;</nowiki> |
|
<nowiki>&lt;</nowiki> |
|
Template:
rp, rt, ruby
संपादन करीं<ruby>...</ruby>
marks spans of phrasing content with ruby annotations.
<rt>...</rt>
marks the ruby text component of a ruby annotation.
<rp>...</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.
Markup | Renders as |
---|---|
<ruby> 東<rp>(</rp><rt>とう</rt><rp>)</rp> 京<rp>(</rp><rt>きょう</rt><rp>)</rp> </ruby> |
東 京 |
<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 not appropriate when indicating document edits; to mark a span of text as having been removed from a document, use the <del>
Markup | Renders as |
---|---|
<s>HyperText Markup Language</s> |
|
Template: {{strikethrough}}
samp
संपादन करीं<samp>...</samp>
indicates output from a program or computing system.
Markup | Renders as |
---|---|
<samp><kbd>HyperText Markup Language</samp></nowiki> |
HyperText Markup Language |
Template: {{samp}} applies gray styling
small
संपादन करीं<small>...</small>
format small text.
Markup | Renders as |
---|---|
<small>HyperText Markup Language</small> |
HyperText Markup Language |
strong
संपादन करीं<strong>...</strong>
formats a span of text with strong importance.
Markup | Renders as |
---|---|
<strong>HyperText Markup Language</strong> |
HyperText Markup Language |
Templates: {{strong}}
sub
संपादन करीं<sub>...</sub>
formats a span of text as a subscript.
Markup | Renders as |
---|---|
HyperText <sub>Markup Language</sub> |
HyperText Markup Language |
Templates:
- {{sub}} (subscript text)
- {{subsub}} (subscript subscript text)
- {{ssub}} (subscript, small text)
- {{sup}} (superscript text)
- {{su}} (superscript
subscript text) - {{sup sub}} (textsup
sub) - {{e}} (1.23×104)
sup
संपादन करीं<sup>...</sup>
formats a span of text as a superscript.
Markup | Renders as |
---|---|
HyperText <sup>Markup Language</sup> |
HyperText Markup Language |
Templates:
- {{sub}} (subscript text)
- {{subsub}} (subscript subscript text)
- {{ssub}} (subscript, small text)
- {{sup}} (superscript text)
- {{su}} (superscript
subscript text) - {{sup sub}} (textsup
sub) - {{e}} (1.23×104)
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> |
|
<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 |
var
संपादन करीं<var>...</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.
Markup | Renders as |
---|---|
<var>HyperText Markup Language</var> |
HyperText Markup Language |
Template: {{varserif}} formatted in italic serif to differentiate characters
Lists
संपादन करींDo not leave blank lines between items in a 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 definition list of group names corresponding to values. Group names are in bold and values are indented. Each group must include one or more definitions.
Markup | Renders as |
---|---|
<dl> <dt> Term <dd> Definition1 <dd> Definition2 <dd> Definition3 <dd> Definition4 </dl> |
|
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 :Definition1 :Definition2 :Definition3 :Definition4 |
|
Template: {{defn}}
ol, ul, li
संपादन करीं<ol>...</ol>
represents an ordered list; <ul>...</ul>
represents an unordered list; <li>...</li>
represents a list item. See [[]].
Markup | Renders as |
---|---|
<ul> <li>Item1</li> <li>Item2</li> <li>Item3</li> <li>Item4</li> </ul> |
|
<ol> <li>Item1</li> <li>Item2</li> <li>Item3</li> <li>Item4</li> </ol> |
|
Wikimarkup: use *
for items in an unordered list and #
for ordered lists.
Markup | Renders as |
---|---|
* Item1 * Item2 * Item3 * Item4 |
|
# Item1 # Item2 # Item3 # Item4 |
|
Templates: for a variety of specialized uses, see Category:Wikipedia list formatting templates.
Sections
संपादन करींdiv
संपादन करीं<div>...</div>
is a a generic container for flow content that displays as a block element.
Markup | Renders as |
---|---|
<div>HyperText Markup Language</div> |
HyperText Markup Language
|
span
संपादन करीं<span>...</span>
is a container for flow content that displays as an inline element.
Markup | Renders as |
---|---|
<span>HyperText Markup Language</span> |
HyperText Markup Language |
Tables
संपादन करीं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> |
| ||
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> |
| ||||
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> |
| ||
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.
big
संपादन करीं<big>...</big>
(obsolete) formats text in a larger font size.
Markup | Renders as |
---|---|
<big>HyperText Markup Language</big> |
HyperText Markup Language |
Template: {{big}} uses CSS.
center
संपादन करीं<center>...</center>
(obsolete) is used to center text elements.
Markup | Renders as |
---|---|
<center>HyperText Markup Language</center> |
|
Template: {{center}} uses CSS.
font
संपादन करीं<font>...</font>
(obsolete) is used to set the font size, font face and color of text.
Markup | Renders as |
---|---|
<font size="3" face="verdana" color="green">HyperText Markup Language</font> |
HyperText Markup Language |
Template: {{font}} uses CSS.
rb
संपादन करीं<rb>...</rb>
(obsolete) Formerly used to mark base text in a ruby annotation; use <ruby>
.
strike
संपादन करीं<strike>...</strike>
(obsolete) formats strike-through characters; use <s>
instead.
Markup | Renders as |
---|---|
<strike>HyperText Markup Language</strike> |
|
tt
संपादन करीं<tt>...</tt>
(obsolete) formats text in a fixed-width font. In general, use {{code}} instead.
Markup | Renders as |
---|---|
<tt>HyperText Markup Language</tt> |
HyperText Markup Language |
Unsupported elements
संपादन करींThese elements are not supported, but have equivalent wiki markup.
<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.
Attributes
संपादन करींMost tags can have a style
attribute. For example
Markup | Renders as |
---|---|
This is <span style="color:red">red</span> 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.
Markup | Renders as |
---|---|
<div class="infobox">Example infobox</div> |
|
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"
Markup | Renders as |
---|---|
a height of {{h:title|6.1 km|20000 ft}} above sea level |
a height of 20000 ft above sea level |
HTML Tidy
संपादन करींHTML Tidy is enabled for the English Wikipedia. Tidy parses the MediaWiki output and cleans it up to ensure that valid HTML is rendered. For example, <br>
, </br>
, <br/>
, <br.>
will all render as <br />
. Tidy is not enabled for MediaWiki interface pages. Tidy is not perfect, and has been known to introduce errors.
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>...</span>
produces the HTML <span id=abc> rendered by the browser as <span id=abc>...</span>
. Some others are interpreted as pure HTML (thus any tag can be used, but wikicode won't be transformed to HTML).
User and sitewide CSS and JS pages (see Help:User style) are interpreted as if inside a <pre>
block.
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.
Parser and extension tags
संपादन करींThe MediaWiki software adds elements that look and act like HTML tags. Parser tags are included in MediaWiki whereas extension tags are added by optional software extensions.
- Extension tags
<categorytree>
,<charinsert>
,<hiero>
,<imagemap>
,<inputbox>
,<math>
,<poem>
,<ref>
,<references>
,<syntaxhighlight>
,<timeline>
References
संपादन करीं- ↑ Allowable elements are defined in the sanitizer.php module.
External links
संपादन करीं- HTML 4.01 specification: elements | 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 $wgRawHtml for a more complete list
- Within the MediaWiki codebase, these HTML checks happen in includes/Sanitizer.php