<tag>…</tag>
- This page is about 'displaying' markup tags. For 'using' markup tags, see the #tag magic word
The {{Tag}} template is designed to made demonstrating techniques involving HTML/XML/XHTML and other markup-style tag structures easier for editors and more accessible for readers by producing clear and logical preformatted output. It supports demonstrating tag pairs, single opening or closing tags, self-closing tags and tags surrounding other content, as well as linking tag names to more targeted documentation about themselves.
A markup tag is paired open (<
) and close (>
) angle brackets, and the content within them, in a markup language such as XML or HTML. For example, the <title> tag defines the title of a web page as see in your browser's title bar.
Usage
[edit]{{Tag|tag name|type|content=text|attribs=attributes and values}}
Parameters
[edit]- See also: Span and div
Required parameters are shown in bold italics.
|1=
(tag name above)- The XML/HTML tag's name (e.g. code, ref).
|2=
(type above)- To indicate which of the tag's types is/are presented:
p
/pair
(default)- A matching pair of open and close tags (e.g.
<div>…</div>
).
To suppress the ellipsis (…
) between the tags, add an empty|content=
parameter (for example,{{Tag|div|pair|content=}}
). o
/open
)- An open tag (e.g.
<span>
). c
/close
- A close tag (e.g.
</span>
). e
/empty
/s
/single
/v
/void
- An empty element, formed as a single, self-terminating tag (e.g.
<hr />
); in HTML5 these are now known as "void" elements, though "empty" is the more common term.
|content=
- Text to place between open and close tags.
|attribs=
/|params=
- Attributes and values to be included as part of an open tag.
|wrap=yes
- Disable nowrap for long samples, allowing line breaks with the tag-wrapped content.
|link=yes
- Link to the element's entry at the HTML element English Wikipedia article, e.g.:
{{Tag|del|link=y}}
produces:
<del>…</del>
This is only for HTML elements; the page is hard-coded, so it cannot be used for, e.g., XML elements from a particular schema. If desired, a feature for specifying the link page can be added.
Examples
[edit]- {{Tag|ref}} →
<ref>…</ref>
- {{Tag|ref|content=}} →
<ref></ref>
- {{Tag|ref|content=hello}} →
<ref>hello</ref>
- {{Tag|span|content=foo}} →
<span>foo</span>
- {{Tag|span|open}} →
<span>
- {{Tag|span|open|content=hello}} →
<span>hello
- {{Tag|span|close|content=hello}} →
hello</span>
- {{Tag|span|pair|content=hello}} →
<span>hello</span>
- {{Tag|ref|open|attribs=group="note"}} →
<ref group="note">
- {{Tag|references|single}} →
<references />
- {{Tag|br|single}} →
<br />
- {{Tag|!--|content= Comment }} →
<!-- Comment -->
- {{Tag|math|attribs=chem}} →
<math chem>…</math>
- {{Tag|a|attribs=href="https://en.wikipedia.org/"|content=English Wikipedia}} →
<a href="https://en.wikipedia.org/">English Wikipedia</a>
TemplateData
[edit]This is the TemplateData for Template:Tag, for use by TemplateWizard, VisualEditor and other tools.
Template description
Produce preformatted examples of markup-style (HTML, XML…) tags in a monospace font
Parameter | Description | Type | Status | |
---|---|---|---|---|
Tag name | 1 | The name of the tag (appears immediately after the < character
| Line | required |
Output type | 2 | Select the desired tag output structure from among: close only, empty/single/void and pair
| Line | required |
Tag-wrapped content | content | The text content to be shown "wrapped" by the tags, immediately following the open tag and/or followed by the close tag
| Content | optional |
Tag attributes | attribs params | Additional tag attributes to be shown following the tag name in the open tag; only valid when output type is set to: e/empty, o/open, p/pair, s/single or v/void
| Line | optional |
Link tag name | link | Links the tag name to the English Wikipedia article section that describes it when assigned any value
| Line | optional |
Allow line breaks | wrap | Remove class=nowrap from the span tags generated to contain the template output, permitting line breaks as needed
| Line | optional |
Custom CSS styles | style | Add custom CSS style declarations to the span tags that enclose the template output
| Line | optional |
See also
[edit]- HTML tag on English Wikipedia
- #tag:, the parser function that generates working tags.