More actions
No edit summary |
No edit summary |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
<!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]). --> | <!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]). --> | ||
{{Cascade-protected template}} | {{Cascade-protected template}} | ||
{{#ifeq:{{ROOTPAGENAME}}|Tooltip|{{Uses TemplateStyles|Template:Tooltip/styles.css}}}} | {{#ifeq:{{ROOTPAGENAME}}|Tooltip|{{Uses TemplateStyles|Template:Tooltip/styles.css}}}} | ||
Wikipedia uses two separate templates to generate tooltips. The {{tl|abbr}} template is used to write an abbreviation (including an acronym or initialism) with its expanded meaning. It is a wrapper for the HTML element {{tag|abbr}}. The {{tl|tooltip}} template uses the {{tag|span}} element to provide generic notes. | Wikipedia uses two separate templates to generate tooltips. The {{tl|abbr}} template is used to write an abbreviation (including an acronym or initialism) with its expanded meaning. It is a wrapper for the HTML element {{tag|abbr}}. The {{tl|tooltip}} template uses the {{tag|span}} element to provide generic notes. | ||
'''Only use {{tnull|abbr}} or {{tag|abbr|o}} to mark up abbreviations (including acronyms and initialisms).''' Using it to generate tooltips elsewhere is a misuse of the underlying HTML and causes | '''Only use {{tnull|abbr}} or {{tag|abbr|o}} to mark up abbreviations (including acronyms and initialisms).''' Using it to generate tooltips elsewhere is a misuse of the underlying HTML and causes accessibility problems. For general-purpose tooltips, use {{tlx|tooltip}} instead. | ||
Readers on '''mobile devices''' typically do not have a mouse to hover with, and so generally cannot see tooltip contents. As of 2023, more English Wikipedia page views occur on mobile than on desktop browsers.[https://stats.wikimedia.org/#/en.wikipedia.org/reading/total-page-views/normal|bar|2-year|access~desktop*mobile-app*mobile-web|monthly] | Readers on '''mobile devices''' typically do not have a mouse to hover with, and so generally cannot see tooltip contents. As of 2023, more English Wikipedia page views occur on mobile than on desktop browsers.[https://stats.wikimedia.org/#/en.wikipedia.org/reading/total-page-views/normal|bar|2-year|access~desktop*mobile-app*mobile-web|monthly] | ||
| Line 30: | Line 26: | ||
== Examples == | == Examples == | ||
When hovering over the text "{{abbr|LSD|Louisiana School for the Deaf}}", something like <span class="titlehint" style="border: 1px solid black; background-color: #FFFFE0; margin-right: 2px; padding: 1px 2px; font-size: smaller; box-shadow: 2px 2px 3px #A0A0A0;">Louisiana School for the Deaf</span> will appear as a tooltip in desktop browsers. Mobile devices may display a dotted line or other visual indicator of abbreviation, but ''will not'' provide the tooltip. No screen readers for the visually impaired will read the expansion by default; some provide an optional setting to read the expansion aloud. | When hovering over the text "{{abbr|LSD|Louisiana School for the Deaf}}", something like <span class="titlehint" style="border: 1px solid black; background-color: #FFFFE0; margin-right: 2px; padding: 1px 2px; font-size: smaller; box-shadow: 2px 2px 3px #A0A0A0;">Louisiana School for the Deaf</span> will appear as a tooltip in desktop browsers. Mobile devices may display a dotted line or other visual indicator of abbreviation, but ''will not'' provide the tooltip. No screen readers for the visually impaired will read the expansion by default; some provide an optional setting to read the expansion aloud. | ||
=== Abbr examples === | === Abbr examples === | ||
In the above example, each abbreviation is first expanded in the body text within parentheses. The template provides an ''additional'' way for some users to access the meaning later in the text. See MOS:ABBR for more information. | |||
In the above example, all abbreviations are expanded via the template. This is discouraged because it is the ''only'' way for users to access the meaning. Users reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning. | In the above example, all abbreviations are expanded via the template. This is discouraged because it is the ''only'' way for users to access the meaning. Users reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning. | ||
In the above example, all abbreviations are expanded via the template, and an entire sentence is embedded via the template. It is the ''only'' way for users to access the meaning. A user reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning of the abbreviation and will have no clear indication that the embedded footnote exists. | In the above example, all abbreviations are expanded via the template, and an entire sentence is embedded via the template. It is the ''only'' way for users to access the meaning. A user reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning of the abbreviation and will have no clear indication that the embedded footnote exists. | ||
===Tooltip example=== | ===Tooltip example=== | ||
Tooltips should not be used within the body text of an article if possible (see MOS:NOTOOLTIPS). Generic tooltip notes are not a substitute for footnotes and are intended to be used for navigational and other secondary features where space is limited. See Template:Glossary link or Template:Cite book/doc#Usage for practical examples. | |||
Tooltips should not be used within the body text of an article if possible (see | |||
== Linking == | == Linking == | ||
{{Notice|Preferably use | {{Notice|Preferably use instead.}} | ||
To wiki-link the abbreviation being marked up by this template, wrap the template in the link, or the tooltip will not appear in some browsers. | To wiki-link the abbreviation being marked up by this template, wrap the template in the link, or the tooltip will not appear in some browsers. | ||
| Line 84: | Line 49: | ||
!Renders as | !Renders as | ||
|- | |- | ||
! | ! | ||
|{{code|<nowiki>[[Knockout#Technical knockout|{{abbr|TKO|technical knockout}}]]</nowiki>}} | |{{code|<nowiki>[[Knockout#Technical knockout|{{abbr|TKO|technical knockout}}]]</nowiki>}} | ||
|Knockout | |Knockout | ||
|- | |- | ||
! | ! | ||
|{{code|<nowiki>{{abbr|[[Knockout#Technical knockout|TKO]]|technical knockout}}</nowiki>}} | |{{code|<nowiki>{{abbr|[[Knockout#Technical knockout|TKO]]|technical knockout}}</nowiki>}} | ||
|Knockout | |Knockout | ||
| Line 99: | Line 64: | ||
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]. 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 markup and makes our content {{em|invalid HTML}} (it will falsely pass a basic 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). | 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]. 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 markup and makes our content {{em|invalid HTML}} (it will falsely pass a basic 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). | ||
{{tl|Tooltip}} is a separate template sharing the same documentation. | {{tl|Tooltip}} is a separate template sharing the same documentation. | ||
| Line 192: | Line 152: | ||
</TemplateData> | </TemplateData> | ||
}} | }} | ||
<includeonly>{{Sandbox other|| | <includeonly>{{Sandbox other|| | ||
Latest revision as of 05:57, 14 April 2025
| This page uses Creative Commons Licensed content from Wikipedia (view authors). |
| This is a documentation subpage for Template:Abbr It may contain usage information, categories and other content that is not part of the original template page. |
| This template can only be edited by administrators because it is transcluded onto one or more cascade-protected pages. |
Wikipedia uses two separate templates to generate tooltips. The {{abbr}} template is used to write an abbreviation (including an acronym or initialism) with its expanded meaning. It is a wrapper for the HTML element <abbr>...</abbr>. The {{tooltip}} template uses the <span>...</span> element to provide generic notes.
Only use {{abbr}} or <abbr> to mark up abbreviations (including acronyms and initialisms). Using it to generate tooltips elsewhere is a misuse of the underlying HTML and causes accessibility problems. For general-purpose tooltips, use {{tooltip}} instead.
Readers on mobile devices typically do not have a mouse to hover with, and so generally cannot see tooltip contents. As of 2023, more English Wikipedia page views occur on mobile than on desktop browsers.[1]
Usage
{{Abbr|text to display inline in the article|pop-up tip}}
Parameters
Two unnamed (positional) parameters (required) and three named parameters (optional):
|1=– the term to be explained; displays as text. Wiki markup is allowed but works more consistently when wrapping the template, see below for linking examples.|2=– the tooltip/pop-up (no wiki or html markup allowed). The popup is created by an HTMLtitle=attribute, so it cannot contain HTML (or markup that resolves to HTML when rendered). This includes simple things like''italics''.|class=– one or more CSS classes (space-separated if more than one)|id=– an HTML id must be unique on the entire page.|style=– CSS to apply to the displayed text (no effect on tooltip/popup). Any style values with embedded blanks must be single-quoted, e.g.|style=font-family: 'Times New Roman', serif;
Examples
When hovering over the text "LSD", something like Louisiana School for the Deaf will appear as a tooltip in desktop browsers. Mobile devices may display a dotted line or other visual indicator of abbreviation, but will not provide the tooltip. No screen readers for the visually impaired will read the expansion by default; some provide an optional setting to read the expansion aloud.
Abbr examples
In the above example, each abbreviation is first expanded in the body text within parentheses. The template provides an additional way for some users to access the meaning later in the text. See MOS:ABBR for more information.
In the above example, all abbreviations are expanded via the template. This is discouraged because it is the only way for users to access the meaning. Users reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning.
In the above example, all abbreviations are expanded via the template, and an entire sentence is embedded via the template. It is the only way for users to access the meaning. A user reading on a mobile device, reading a printout, or listening to a screen reader will likely not have access to the full meaning of the abbreviation and will have no clear indication that the embedded footnote exists.
Tooltip example
Tooltips should not be used within the body text of an article if possible (see MOS:NOTOOLTIPS). Generic tooltip notes are not a substitute for footnotes and are intended to be used for navigational and other secondary features where space is limited. See Template:Glossary link or Template:Cite book/doc#Usage for practical examples.
Linking
| Preferably use instead. |
To wiki-link the abbreviation being marked up by this template, wrap the template in the link, or the tooltip will not appear in some browsers.
| Compatibility | Markup | Renders as |
|---|---|---|
[[Knockout#Technical knockout|{{abbr|TKO|technical knockout}}]]
|
Knockout | |
{{abbr|[[Knockout#Technical knockout|TKO]]|technical knockout}}
|
Knockout |
Accessibility and validity
The {{Abbr}} template is intended only for use with abbreviations (including acronyms and initialisms).
The Web Content Accessibility Guidelines contain guidelines for using the <abbr> element generated by this template; see section H28: Providing definitions for abbreviations by using the abbr and acronym elements. HTML specifications (both those of the W3C and WHATWG) strictly define the <abbr> element as reserved for markup of abbreviations. Abusing it for mouse-over tooltips breaks our semantic markup and makes our content invalid HTML (it will falsely pass a basic 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).
{{Tooltip}} is a separate template sharing the same documentation.
Maintenance categories
Template data
TemplateData for Abbr