Zeroclanzhang(讨论 | 贡献) (创建页面,内容为“<code class="{{#ifeq:{{{wrap|}}}|yes|wrap|nowrap}}" style="{{#ifeq:{{{style|}}}|plain|border:none;background:transparent;|{{{style|}}}}}"><!-- Opening tag -->{{#switch:{{{2|pair}}} |c|close = |s|single |o|open |p|pair = <{{{1|tag}}}{{#if:{{{params|}}}| {{{params}}}}} }}<!-- Content between tags -->{{#switch:{{{2|pair}}} |c|close = {{{content|}}} |s|single = /> |o|open = >{{{content|}}} |p|pair = {{#ifeq:{{{1|tag}}}|!--||…”) |
Zeroclanzhang(讨论 | 贡献) 无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第2行: | 第2行: | ||
Opening tag | Opening tag | ||
-->{{#switch:{{{2|pair}}} | -->{{#switch:{{{2|pair}}} | ||
|c|close = | |||
|e|empty|s|single|v|void | |||
|o|open | |||
|p|pair = {{#ifeq:{{{1|tag}}}|math|[math|}}{{#if:{{{link|}}}|[[HTML element#{{{1|tag}}}|{{{1|tag}}}]]|{{{1|tag}}}}}{{#if:{{{params|{{{attribs|}}}}}}| {{{params|{{{attribs}}}}}}}}{{#ifeq:{{{1|tag}}}|math||>}} | |||
}}<!-- | |||
Content between tags | Content between tags | ||
-->{{#switch:{{{2|pair}}} | -->{{#switch:{{{2|pair}}} | ||
|c|close = {{{content|}}} | |||
|e|empty|s|single|v|void =  /> | |||
|o|open = >{{{content|}}} | |||
|p|pair = {{#ifeq:{{{1|tag}}}|!--||>}}{{#ifeq:{{{1|tag}}}|math||{{{content|...}}}}} | |||
}}<!-- | |||
Closing tag | Closing tag | ||
-->{{#switch:{{{2|pair}}} | -->{{#switch:{{{2|pair}}} | ||
|e|empty|s|single|v|void | |||
|o|open = | |||
|c|close | |||
|p|pair = {{#ifeq:{{{1|tag}}}|math|[/math]|{{#ifeq:{{{1|tag}}}|!--|-->|</{{{1|tag}}}>}}}} | |||
}}<!-- | |||
--></code><noinclude> | --></code><noinclude> | ||
{{ | {{Documentation}} | ||
</noinclude> | </noinclude> |
2024年1月22日 (一) 00:30的最新版本
tag>>...</tag>
This template is used on many pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
{{tag|tagname [|type] [|content=text] [|attribs=attributes and values]}}
A markup tag is an open < and a close > angle brackets and the content within them, in a markup language, as XML or HTML:
- For example, the <title> tag provides a title for the Web page.
This template provides a quick way to mention a markup-style tag in a preformatted way. Mainly used in discussion/help pages.
Parameters
Required parameters shown in bold italics.
|1=
(tagname 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/start and close/end tags (e.g.
div>>...</div>
).
To suppress the ellipsis ("...") between the tags, add an empty|content=
parameter (for example,div>></div>
). o
(open
)- An open/start tag (e.g.
span>>
). c
(close
)- A close/end tag (e.g.
</span>
). e
(empty
) ors
(single
) orv
(void
)- An empty element, formed with 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/start and close/end tags.
|attribs=
- Attributes and values to be included as part of an open/start tag (this parameter can also be called
|params=
). |wrap=yes
- Disable nowrap for long samples, so allowing wraps (line breaks).
|link=yes
- Link to the element's entry at the HTML element 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
Markup | Renders as |
---|---|
{{tag|ref}} |
|
{{tag|ref|content=}} |
|
{{tag|ref|content=hello}} |
|
{{tag|span|content=foo}} |
|
{{tag|span|open}} |
|
{{tag|span|open|content=hello}} |
|
{{tag|span|close|content=hello}} |
|
{{tag|span|pair|content=hello}} |
|
{{tag|ref|open|attribs=group="note"}} |
|
{{tag|references|single}} |
|
{{tag|br|single}} |
|
{{tag|!--|content=comment}} |
|
{{tag|math|attribs=chem}} |
|
{{tag|a |attribs=href="<nowiki>https://en.wikipedia.org/</nowiki>" |content=English Wikipedia}} |
|
Global use and documentation
For a global use of this template in other sister or Wikimedia projects, after copying it to paste in the destination project, remember to change in the code:
|p|pair = <{{#if:{{{link|}}}|[[HTML element#
by this one:
|p|pair = <{{#if:{{{link|}}}|[[Wikipedia:en:HTML element#
Remark that the code Wikipedia:en:
has been added.
For template documentation in the sister project, you can use Template:Wikipedia doc.
See also
- HTML element
{{模板:XMLElement}}
{{XMLElement}}
{{xtag}}
adds a MediaWiki parser or extension tag that links to the extension page.- #tag:, the parser function that generates working tags.
Other formatting templates
{{#lsth:Template:Template-linking_templates|Other formatting templates}}