Changes

Jump to navigation Jump to search
→‎Usage: clean up example and show both ways of handling an equals sign in a parameter
{{Documentation subpage}} __NOTOC__
<!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]). -->
{{COinS safe|n}}
{{ombox
| type = content
| image = [[File:Stop hand nuvola.svg|40px|alt=Warning|link=]]
| imageright =
| text = The former '''Template:Tooltip''' redirects here. However, this template should not be used for general tooltips, and the redirect is deprecated per [[Wikipedia:Redirects_for_discussion/Log/2018_May_9#Template:Tooltip|this RfD]].
|}}
{{High-risk|391,000+}}
{{hatnote|For inline cleanup templates requesting definitions or explanations, see {{tl|Definition}} and {{tl|Elucidate}}.}}

{{stack|{{template shortcuts|Abbrv|Define|Tooltip}}}}

The template&nbsp;{{tl|Abbr}} is used to write an abbreviation with its meaning. It is a wrapper for the [[HTML]] [[HTML element#General phrase elements|element]] {{tag|abbr}}, the element used by most [[WWW|web]] [[Web browser|browsers]] to create a [[tooltip]] indicating the meaning of an abbreviation or [[acronym]].

{{strong|Please note: Do not use {{tnull|abbr}} or {{tag|abbr|o}} to mark up material other than abbreviations or acronyms. Using it to generate tooltips elsewhere is a misuse of the underlying HTML and causes [[WP:ACCESS|accessibility]] problems.}} See {{tlx|Hover title}} for how to implement similar functionality without abusing markup (though it is also not accessibility-perfect {{as of|lc=y|June 2018|post=;}} input sought at [[Template talk:Hover title]]).

== Usage ==

The template&nbsp;{{tlx|abbr}} takes two unnamed parameters, in order:
;<code>1</code>: {{kbd|{{var|abbreviation}}}} – the abbreviation, acronym, or initialism to be explained; shows as text, and may use wikimarkup, such as a link to an article about what it refers to.
;<code>2</code>: {{kbd|{{var|meaning}}}} – the expansion or definition of the abbreviation; shows as the popup when you hover over the <kbd><var>abbreviation</var></kbd>. {{strong|No wikimarkup}} can be used in this parameter.
These can also be given as explicitly numbered parameters; this is necessary if a parameter's content contains the equals ({{kbd|{{=}}}}) character:
* Complex example: <code><nowiki>[[Mass–energy equivalence|{{</nowiki>'''abbr'''<nowiki>|{{math|''E'' {{=}} ''mc''<sup>2</sup>}}|</nowiki>'''2='''<nowiki>Energy = mass times the speed of light squared}}]]</nowiki></code>
* Produces: [[Mass–energy equivalence|{{abbr|{{math|''E'' {{=}} ''mc''<sup>2</sup>}}|2=Energy = mass times the speed of light squared}}]]


A third unnamed parameter accepts the following values (which have the same effect):
;<code>3</code>: {{kbd|{{var|IPA}}}} or {{kbd|{{var|i}}}} – applies the {{tlx|IPA}} template to fix the [[International Phonetic Alphabet]] rendering on Windows XP.


Named parameters and the input they take:
;<code>class</code>: One or more CSS classes (space-separated if more than one)
;<code>id</code>: An HTML id (i.e., a <code>#{{var|ID name here}}</code> link anchor); this must be unique on the entire page
;<code>style</code>: Arbitrary inline CSS to apply to the {{kbd|abbreviation}} text. For any input that needs to be quotation-marked (e.g. because it contains a space character), use straight single-quotes only, e.g. {{para|style|font-family: 'Times New Roman', serif;}}

== Examples ==

{{markup
|<nowiki>{{abbr|MSLP|Mean Sea Level Pressure}}</nowiki>
|{{abbr|MSLP|Mean Sea Level Pressure}}
}}

When hovering over the text "{{abbr|MSLP|Mean Sea Level Pressure}}", something like {{titlehint|Mean Sea Level Pressure}} will appear as a tooltip in most browsers. Popular [[screen reader]]s, used by visually impaired readers, give the meaning in a different way.

{{markup
|<nowiki>{{abbr|UK|United Kingdom|class=country-name|id=foobar}}</nowiki>
|{{abbr|UK|United Kingdom|class=country-name|id=foobar}}
}}

== Linking must be done a particular way ==
To wiki-link the abbreviation being marked up by this template, wrap the template in the link, not vice-versa, or the meaning will not appear in some browsers, including Chrome.

'''Works:'''
{{markup
|<nowiki>[[Knockout#Technical knockout|{{abbr|TKO|technical knockout}}]]</nowiki>
|[[Knockout#Technical knockout|{{abbr|TKO|technical knockout}}]]
}}

'''Does not work:'''
{{markup
|<nowiki>{{abbr|[[Knockout#Technical knockout|TKO]]|technical knockout}}</nowiki>
|{{abbr|[[Knockout#Technical knockout|TKO]]|technical knockout}}
}}

'''Do not link, or use any other wikimarkup or HTML markup, in the <kbd><var>meaning</var></kbd> (popup) – only plain text.'''<br />
The mouse-over popup for the <kbd><var>meaning</var></kbd> text is created by a <code>title=</code> attribute inside an {{tag|abbr|o}} HTML element's opening tag, so it cannot itself contain any HTML (or markup that resolves to HTML when rendered). This includes simple things like <code><nowiki>''italics''</nowiki></code>.

== Accessibility and HTML validity concerns ==

This template is intended {{em|only}} for use with abbreviations (including acronyms and initialisms).

The [[Web Content Accessibility Guidelines]] contain guidelines for using the {{tag|abbr|o}} element generated by this template; see section [http://www.w3.org/TR/WCAG20-TECHS/H28.html H28: Providing definitions for abbreviations by using the abbr and acronym elements].

Furthermore, the HTML specifications (both those of the [[W3C]] and [[WHATWG]]) strictly define the {{tag|abbr|o}} element as reserved for markup of abbreviations. Abusing it for mouse-over tooltips breaks our [[Semantic HTML|semantic markup]] and makes our content {{em|invalid HTML}} (technically, "not [[Well-formed document|well-formed]]"; it will pass an basic [[Validator|automated validator]] test because such a tool can't tell that the logical application of the data to the structure isn't correct, only that tags are nested properly, etc.).

== Redirects ==

The following template names will [[Wikipedia:Redirect|redirect]] to {{tl|abbr}}:
* {{tl|Abbrv}}
* {{tl|Define}}
* {{tl|Tooltip}} (deprecated)

== Template data ==
{{TemplateDataHeader}}
<TemplateData>
{
"description": "This template defines an abbreviation or acronym, by creating a tooltip that is displayed on mouse-over.",
"params": {
"1": {
"label": "Abbreviation",
"description": "Shows as text",
"type": "string/line",
"required": true
},
"2": {
"label": "Meaning",
"description": "Shows as a tooltip",
"type": "string",
"required": true
},
"IPA": {
"label": "IPA",
"description": "Applies {{IPA}} to fix strings in the International Phonetic Alphabet rendered in Internet Explorer on Windows XP",
"type": "string/line",
"required": false
},
"class": {
"label": "Class",
"description": "Adds a HTML class",
"type": "string/line",
"required": false
},
"id": {
"label": "ID",
"description": "Adds a HTML id",
"type": "string/line",
"required": false
}
}
}
</TemplateData>

== See also ==
* {{tl|abbrlink}}, a variant of this template that includes wikilinking.
* {{tl|H:title}}, used for generating tooltips in general.
* {{tl|R-phrase}}, which generates&nbsp;the abbreviation (the code number) for an [[List of R-phrases|R-phrase]] (a "risk phrase", e.g. "Explosive when dry"). The R-phrase itself and a link to [[List of R-phrases]] are included in a tooltip.
* {{tl|clarify}}, which produces the inline superscript:&nbsp; {{fake clarify}}.
* {{tl|finedetail}}, which allows a main fact to be presented in an article while hiding finer detail which, although factually accurate and maybe of interest to specific readers, might detract from the general readability of the article by cluttering the article if always presented; it allows referencing.

<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go below this line, please; interwikis go to Wikidata, thank you! -->
[[Category:Wikipedia XHTML tag-replacing templates]]
[[Category:Text-specific formatting and function templates]]
[[Category:Semantic markup templates]]

}}</includeonly>
Anonymous user

Navigation menu