Help:HTML fragments
Appearance
(Redirected from Help:Z89)
HTML fragment (Z89) is a special Type for use in embedded function calls.
A subset of the living HTML5 syntax can be used and will appear in the rendered form of the HTML fragment (Z89) (as an evaluation result or in embedded calls), while unsupported elements are treated as plaintext. See the list of elements below.
The main Functions for working with HTML fragments are:
- string to HTML fragment (Z27868) (escaping) / HTML raw content to HTML fragment (Z27861) (non-escaping)
- wrap an HTML fragment in a tag (Z27873)
- join multiple HTML fragments (Z27926)
Others are listed at WF:Catalogue/HTML operations.
Supported HTML elements
Along with the elements in the below table, HTML fragment (Z89) supports numeric and named entities, including the 2 extra rlm aliases specific to MediaWiki, and the custom element ext-wikilambda-image (see Help:Z310).
| Supported on the Web generally? | Element | Supported in Wikitext? |
Supported in Z89? | Notes |
|---|---|---|---|---|
| ✔️ | <!-- comment --> | ✔️ | ✔️ | Unlike Wikitext, comments persist into the page served to readers (on Wikifunctions and AW) |
| ✔️ | <![CDATA[ comment ]]> | ❌️ | ✔️ | Same as regular comments |
| ✔️ | <a/> | ❌️[note 1] | ✔️ | There's an allowlist on the href attribute, limiting hyperlinks to only Wikimedia projects.[which?] |
| ✔️ | <abbr/> | ✔️ | ✔️ | |
| ❌️ | <acronym/> | ❌️ | N/A | |
| ✔️ | <address/> | ❌️ | ❌️ | |
| ✔️ | <area/> | ❌️[note 1] | UNK | |
| ✔️ | <article/> | ❌️ | ❌️ | |
| ✔️ | <aside/> | ❌️ | ❌️ | |
| ✔️ | <audio/> | ❌️[note 2] | UNK | |
| ✔️ | <b/> | ✔️[note 3] | ✔️ | |
| ✔️ | <base/> | ❌️ | N/A | |
| ❌️ | <basefont/> | ❌️ | N/A | |
| ✔️ | <bdi/> | ✔️ | ✔️ | |
| ✔️ | <bdo/> | ✔️ | ✔️ | |
| ❌️ | <big/> | ✔️[note 4] | ❌️ | |
| ✔️ | <blockquote/> | ✔️ | ✔️ | |
| ✔️ | <body/> | ❌️ | N/A | |
| ✔️ | <br/> | ✔️ | ✔️ | |
| ✔️ | <button/> | ❌️[note 5] | UNK | |
| ✔️ | <canvas/> | ❌️[note 6] | UNK | |
| ✔️ | <caption/> | ✔️[note 7] | ✔️ | |
| ❌️ | <center/> | ✔️[note 3] | ❌️ | |
| ✔️ | <cite/> | ✔️ | ❌️ | |
| ✔️ | <code/> | ✔️ | ✔️ | |
| ✔️ | <col/> | ❌️[note 8] | UNK | |
| ✔️ | <colgroup/> | ❌️[note 8] | UNK | |
| ❌️ | <content/> | ❌️[note 9] | N/A | |
| ✔️ | <data/> | ✔️ | ❌️ | |
| ✔️ | <datalist/> | ❌️[note 5] | UNK | |
| ✔️ | <dd/> | ✔️[note 10] | ✔️ | |
| ✔️ | <del/> | ✔️ | ✔️ | |
| ✔️ | <details/> | ❌️ | UNK | |
| ✔️ | <dfn/> | ✔️ | ✔️ | |
| ✔️ | <dialog/> | ❌️[note 5] | UNK | |
| ❌️ | <dir/> | ❌️ | N/A | |
| ✔️ | <div/> | ✔️ | ✔️ | |
| ✔️ | <dl/> | ✔️[note 10] | ✔️ | |
| ✔️ | <dt/> | ✔️[note 10] | ✔️ | |
| ✔️ | <em/> | ✔️ | ✔️ | |
| ✔️ | <embed/> | ❌️[note 11] | UNK | |
| ✔️ | <fieldset/> | ❌️[note 5] | UNK | |
| ✔️ | <figcaption/> | ❌️[note 2] | UNK | |
| ✔️ | <figure/> | ❌️[note 2] | UNK | |
| ❌️ | <font/> | ✔️[note 4] | ❌️ | |
| ✔️ | <footer/> | ❌️ | UNK | |
| ✔️ | <form/> | ❌️[note 5] | UNK | |
| ❌️ | <frame/> | ❌️ | N/A | |
| ❌️ | <frameset/> | ❌️ | N/A | |
| ✔️ | <h1/> | ✔️[note 12] | ✔️ | |
| ✔️ | <h2/> | ✔️[note 12] | ✔️ | |
| ✔️ | <h3/> | ✔️[note 12] | ✔️ | |
| ✔️ | <h4/> | ✔️[note 12] | ✔️ | |
| ✔️ | <h5/> | ✔️[note 12] | ✔️ | |
| ✔️ | <h6/> | ✔️[note 12] | ✔️ | |
| ✔️ | <head/> | ❌️ | N/A | |
| ✔️ | <header/> | ❌️ | UNK | |
| ✔️ | <hgroup/> | ❌️ | UNK | |
| ✔️ | <hr/> | ✔️ | ✔️ | |
| ✔️ | <html/> | ❌️ | N/A | |
| ✔️ | <i/> | ✔️[note 3] | ✔️ | |
| ✔️ | <iframe/> | ❌️[note 11] | UNK | |
| ❌️ | <image/> | ❌️ | N/A | |
| ✔️ | <img/> | ❌️[note 2] | UNK | |
| ✔️ | <input/> | ❌️[note 5] | UNK | |
| ✔️ | <ins/> | ✔️ | ✔️ | |
| ✔️ | <kbd/> | ✔️ | ✔️ | |
| ✔️ | <label/> | ❌️[note 5] | UNK | |
| ✔️ | <legend/> | ❌️[note 5] | UNK | |
| ✔️ | <li/> | ✔️[note 10] | ✔️ | |
| ✔️ | <link/> | ✔️[note 13] | ❌️ | |
| ✔️ | <main/> | ❌️ | UNK | |
| ✔️ | <map/> | ❌️[note 1] | UNK | |
| ✔️ | <mark/> | ✔️ | ❌️ | |
| ❌️ | <marquee/> | ❌️ | N/A | |
| ✔️ | <math/> | ❌️[note 14] | UNK | |
| ✔️ | <menu/> | ❌️ | UNK | |
| ❌️ | <menuitem/> | ❌️ | N/A | |
| ✔️ | <meta/> | ✔️[note 13] | ❌️ | |
| ✔️ | <meter/> | ❌️ | UNK | |
| ✔️ | <nav/> | ❌️ | UNK | |
| ❌️ | <nobr/> | ❌️ | N/A | |
| ❌️ | <noembed/> | ❌️ | N/A | |
| ❌️ | <noframes/> | ❌️ | N/A | |
| ✔️ | <noscript/> | ❌️[note 6] | UNK | |
| ✔️ | <object/> | ❌️[note 11] | UNK | |
| ✔️ | <ol/> | ✔️[note 10] | ✔️ | |
| ✔️ | <optgroup/> | ❌️[note 5] | UNK | |
| ✔️ | <option/> | ❌️[note 5] | UNK | |
| ✔️ | <output/> | ❌️[note 5] | UNK | |
| ✔️ | <p/> | ✔️ | ✔️ | |
| ❌️ | <param/> | ❌️ | N/A | |
| ✔️ | <picture/> | ❌️[note 2] | UNK | |
| ❌️ | <plaintext/> | ❌️ | N/A | |
| ✔️ | <pre/> | ✔️[note 15] | ❌️ | <span style="white-space: pre;" /> works. |
| ✔️ | <progress/> | ❌️ | UNK | |
| ✔️ | <q/> | ✔️ | ✔️ | |
| ❌️ | <rb/> | ❌️ | N/A | |
| ❌️ | <rbc/> | ❌️ | N/A | |
| ❌️ | <ref/> | ✔️ | ❌️ | |
| ✔️ | <rp/> | ✔️ | ❌️ | See <ruby/>. |
| ✔️ | <rt/> | ✔️ | ❌️ | See <ruby/>. |
| ❌️ | <rtc/> | ❌️ | N/A | |
| ✔️ | <ruby/> | ✔️ | ❌️ | Will revisit once there's demand—tracked as phab:T419365. |
| ✔️ | <s/> | ✔️[note 3] | ✔️ | |
| ✔️ | <samp/> | ✔️ | ❌️ | |
| ✔️ | <script/> | ❌️[note 6] | UNK | |
| ✔️ | <search/> | ❌️ | UNK | |
| ✔️ | <section/> | ❌️[note 16] | UNK | |
| ✔️ | <select/> | ❌️[note 5] | UNK | |
| ❌️ | <shadow/> | ❌️[note 9] | N/A | |
| ✔️ | <slot/> | ❌️[note 9] | UNK | |
| ✔️ | <small/> | ✔️[note 4] | ❌️ | reduce font size of HTML fragment (Z40086) does the same thing with a span. |
| ✔️ | <source/> | ❌️[note 2] | UNK | |
| ✔️ | <span/> | ✔️ | ✔️ | |
| ❌️ | <strike/> | ❌️[note 3] | N/A | |
| ✔️ | <strong/> | ✔️ | ✔️ | |
| ✔️ | <style/> | ❌️[note 17] | UNK | |
| ✔️ | <sub/> | ✔️ | ✔️ | |
| ✔️ | <summary/> | ❌️ | UNK | |
| ✔️ | <sup/> | ✔️ | ✔️ | Adding class="ext-wikilambda-reference" will turn it into a citation, see mw:Help:Wikifunctions/Citations. |
| ✔️ | <svg/> | ❌️[note 18] | UNK | |
| ✔️ | <table/> | ✔️[note 7] | ✔️ | |
| ✔️ | <tbody/> | ❌️[note 8] | ❌️ | |
| ✔️ | <td/> | ✔️[note 7] | ✔️ | |
| ✔️ | <template/> | ❌️[note 9] | UNK | |
| ✔️ | <textarea/> | ❌️[note 5] | UNK | |
| ✔️ | <tfoot/> | ❌️[note 8] | UNK | |
| ✔️ | <th/> | ✔️[note 7] | ✔️ | |
| ✔️ | <thead/> | ❌️[note 8] | UNK | |
| ✔️ | <time/> | ✔️ | ❌️ | |
| ✔️ | <title/> | ❌️ | N/A | |
| ✔️ | <tr/> | ✔️[note 7] | ✔️ | |
| ✔️ | <track/> | ❌️[note 2] | UNK | |
| ❌️ | <tt/> | ✔️[note 4] | ❌️ | |
| ✔️ | <u/> | ✔️[note 3] | ✔️ | |
| ✔️ | <ul/> | ✔️[note 10] | ✔️ | |
| ✔️ | <var/> | ✔️ | ❌️ | |
| ✔️ | <video/> | ❌️[note 2] | UNK | |
| ✔️ | <wbr/> | ✔️ | ❌️ | |
| ❌️ | <xmp/> | ❌️ | N/A |
- 1 2 3
In Wikitext, hyperlinks can only be made via
[target label]syntax. There is no way to set therelattribute. Image maps can only be made via the<imagemap/>tag hook from mw:Extension:ImageMap.
In an HTML fragment (Z89), the Wikitext syntax has no meaning, and the HTML<a href="target">label</a>syntax is required. - 1 2 3 4 5 6 7 8 Wikitext has dedicated syntax for embedding media, and without extensions it's limited to local resources.
- 1 2 3 4 5 6
The elements
<b/>,<i/>,<u/>,<s/>,<strike/>, and<center/>encode no semantic meaning, the latter two being formally deprecated. To maintain content–presentation seperation on the Web, CSS is preferred over these. In Wikitext, there's dedicated syntax for bold and italics. There are also the semantic elements<strong/>,<em/>,<ins/>, and<del/>. - 1 2 3 4
The elements
<font/>,<tt/>,<big/>, and<small/>encode no semantic meaning, the former three being formally deprecated. CSS is preferred over these. - 1 2 3 4 5 6 7 8 9 10 11 12 13 Wikitext does not support forms or input widgets.
- 1 2 3
Embedded or linked JavaScript isn't supported in Wikitext.
Thus
<canvas/>and<noscript/>are disallowed too. - 1 2 3 4 5 Wikitext has dedicated syntax for tables, but the HTML syntax is also supported, at least the parts corresponding to the features of Wikitext tables.
- 1 2 3 4 5 Some elements used for marking up tables aren't usable in Wikitext (and have no equivalent native syntax).
- 1 2 3 4 Web Components aren't supported in Wikitext. Modularity is achieved with transclusion.
- 1 2 3 4 5 6 Wikitext has dedicated syntax for unordered lists, ordered lists, and definition lists, but the HTML syntax is also supported.
- 1 2 3 Wikitext does not support iframes or embedded objects.
- 1 2 3 4 5 6 Wikitext has dedicated syntax for the various levels of headings.
- 1 2
<link/>can only be used if it has bothitempropandhref.<meta/>can only be used if it has bothitempropandcontent. - ↑
Embedded MathML isn't supported in Wikitext.
There is a
<math/>tag hook from mw:Extension:Math, but while it produces embedded MathML, it only accepts a TeX-based syntax. - ↑ Wikitext has dedicated syntax for preformatted/unparsed text, but the HTML syntax is also supported.
- ↑
Wikitext does not support the semantic container elements such as
<section/>. There is a<section/>tag hook from mw:Extension:Labeled Section Transclusion, but it's not equivalent. - ↑ Embedded stylesheets aren't supported in Wikitext (though inline styles are).
- ↑ Embedded SVG isn't supported in Wikitext.