Template:Dfn/doc

Usage
This template applies the HTML phrase element  around the text given as the first parameter, the term, and, if the optional second definition parameter is present, applies a dotted underline (a common style throughout the Web for indicating a term with a definition feature) and a definition pop-up "tool tip" when cursor focus is on the term.

Without the second parameter, it does not do anything user-facing, and is just a form of meta-data that can be detected and acted upon by internal and external software (statistics-gathering bots, rich Web 2.0 applications, etc.), and can provide valuable contextual information to editors.

It is used as a meta-template by some other templates. When used by itself, its most common purpose would be around a term boldfaced in an article and immediately defined there such as a key piece of terminology introduced after the lead section. Wikipedia is not a dictionary, so this template should not be used to draw metadata attention to everyday words, and is best suited in spots where there is a short definition or clarification of jargon that is important in the context.

(Tech detail: By using an internal with its own independent   attribute for tool tip fun, it sets this up in a way that does not violate the HTML 5 specification on the handing of the   attribute of, which is the exact term defined, not its definition.)

Purpose and application
This markup indicates that the text is the defining instance of that term (word, phrase, name, etc.) on the page in which it appears. Thus it should be used only once per term per page.

Wikipedia is not a dictionary, so this template should not be used to provide definitions for everyday words at all, and is best suited for short definition or clarification of jargon that is important in the context but unlikely to be fully understood by all of our general readership. The template can be adapted to most directly editable cases in which the  element would be useful.

Because the definition parameter's content is not readily accessible to users of most if not all screen reader software, text-only browsers, mobile phone browsers, etc., the second parameter should never be used to provide information vital to understanding the article subject, only convenient or augmenting for those who can access it; vital information belongs in the main article prose.

This template should not be used for marking up glossary entries or links to them; see term and glossary link instead, respectively. Likewise, this template should not be used to mark up the bold-faced article subject in the lead; [it is anticipated that] another template, [name forthcoming, probably Template:Subject], is [to be created to be] used for this purpose, including the needed bold-facing and [perhaps] other markup and metadata features.

This is semantic markup, not simply presentational style, and has a particular, pre-defined meaning; do not misuse this template just to get its display effects. If the content being marked up is not suitable for the  element as defined by the W3C HTML specifications, then you should not use this template.

Parameters
There are two basic parameters, the mandatory first parameter, the term, and the optional second one, the definition :

If the definition parameter is supplied and the reader's browser supports the functionality, moving browser focus to the term (e.g., hovering the mouse cursor over it, or in some browsers using keyboard navigation to tab to it) will change the cursor to the "help" version (usually a question mark) and bring up the definition text in a pop-up tool tip (or some other interface, as provided by the browser in question). Without a second parameter, no such underlining and tool tip effects occur.

It is safest to explicitly number them, but this is only absolutely required if the content contains an equals sign somewhere:
 * – this works if only the definition has a "=" in it.
 * – this fails; if parameter 1 is numbered, so must be parameter 2
 * – this fails; if parameter 1 is numbered, so must be parameter 2

If no definition is provided, the template is invisible:
 * results in:
 * results in:, the moulting of the exoskeleton
 * results in: Ecdysis

The "invisible" second and third cases won't be noticed by casual readers, but can still be detected and acted upon by internal and external software (statistics-gathering bots, rich Web 2.0 applications, etc.), and can provide valuable contextual information to editors.

The definition parameter is most commonly omitted when the text following the term provides the defining content inline in the prose, or when the term is linked to an explanation elsewhere, as shown above. A common case of this is when an article provides a bold-faced term and an explanation of it, often at the start of a paragraph or section, indicating a significant side-topic in the article, subordinate to the main article subject boldfaced in the lead.

Other optional parameters
Real-world example: showing imprecise term in text and its precise official name as the title, with escaped quotation marks:, which results in: (hover over it to see that tooltip is different from base content)
 * exact, plaintext term being defined – used a) when the content in the first parameter (term) contains any wikimarkup or HTML; or b) when the term being defined is actually slightly different from (i.e. more precise than) the marked up content; the true term being defined goes in this parameter. Any double-quotation mark must be escaped, as.


 * an_ID – an ID (no spaces, must begin with alphabetic letter) for #linking and possibly other purposes
 * arbitrary:css; – CSS directives for custom-styling the instance
 * css_class – a CSS class or classes (separated by spaces not commas if more than one)

Problem characters
If there would be a " " (equals sign) in the term, either a) both unnamed parameters if present must explicitly be numbered:
 * which results in:

or b) the character itself can be escaped as the HTML character entity reference code  or the &lcub;&lcub;=&rcub;&rcub; magic word:
 * which results in:
 * which results in:

No other characters are known to be problematic in the term.

For technical reasons, the second parameter (2, the definition ) is more "brittle". The equals sign must be escaped by one of the techniques just mentioned,  the standard keyboard (straight, not curly) double-quotation mark  must also be escaped, no matter what, as   or. This double-quote must also be escaped the same way in the title parameter:
 * which results in:
 * which results in:
 * which results in:
 * which results in:

Links and markup
Linking and wikimarkup should be done the template when possible:
 * Right:
 * Wrong:

The term content in the first parameter be marked up with wikimarkup or HTML, at the   level, such as italics, superscript other text-formatting code (versus  -level elements, such as paragraphs, tables, block quotations, and so on), if absolutely necessary. If this is done, the title parameter contain the un-marked-up, plaintext term. Example: The displayed text (first parameter) uses superscript markup, for accessibility reasons, while the real plaintext in the title parameter uses a Unicode character entity (doesn't count as wikimarkup) for a superscripted 2, which is actually more correct but may not display properly on older systems:

yields:

while this:

gives:

Note that in the first case, the mouse hover tooltip is the Unicode version of the term, as given in the title, while in the latter it is the definition given in the 2 parameter.

Linked version:

gives:
 * Mass–energy equivalence

It still has a dotted underline indicating a tooltip, but is also a bluelink. Mouse hovering shows both the tooltip and, in the status bar, the target URL, in browsers that support these features.

Link inside the :

results in:

This doesn't mess up the page, but the definition fails and there's no tooltip cursor, meanwhile the markup is hard for other editors to understand anyway so it is deprecated.

Links, HTML, wikimarkup, and other markup cannot be applied to content in the 2 ( definition ) parameter, nor in a title parameter, only plain text and character entity references ("&-codes", like ).

Anchors and id
Example where an anchor is added. Because  is missing, no text appears when the mouse hovers over the newly defined term " ".



results in:


 * An  is defined as ... This makes it an example of an open set.

Contrast to the alternative that uses the visible anchor template:



which results in:


 * An is defined as ...  This makes it an example of an open set.

Note that clicking on the "open set" link results in the text being highlighted.