Path: blob/main/files/en-us/web/html/element/dfn/index.md
6532 views
------{{HTMLSidebar}}
The <dfn> HTML element is used to indicate the term being defined within the context of a definition phrase or sentence. The ancestor {{HTMLElement("p")}} element, the {{HTMLElement("dt")}}/{{HTMLElement("dd")}} pairing, or the nearest {{HTMLElement("section")}} ancestor of the <dfn> element, is considered to be the definition of the term.
{{EmbedInteractiveExample("pages/tabbed/dfn.html", "tabbed-shorter")}}
Attributes
This element's attributes include the global attributes.
The {{htmlattrxref("title")}} attribute has special meaning, as noted below.
Usage notes
There are some not-entirely-obvious aspects to using the <dfn> element. We examine those here.
Specifying the term being defined
The term being defined is identified following these rules:
If the
<dfn>element has a {{htmlattrxref("title")}} attribute, the value of thetitleattribute is considered to be the term being defined. The element must still have text within it, but that text may be an abbreviation (perhaps using {{HTMLElement("abbr")}}) or another form of the term.If the
<dfn>contains a single child element and does not have any text content of its own, and the child element is an {{HTMLElement("abbr")}} element with atitleattribute itself, then the exact value of the<abbr>element'stitleis the term being defined.Otherwise, the text content of the
<dfn>element is the term being defined. This is shown in the first example below.
Note: If the
<dfn>element has atitleattribute, it must contain the term being defined and no other text.
Links to <dfn> elements
If you include an {{htmlattrxref("id")}} attribute on the <dfn> element, you can then link to it using {{HTMLElement("a")}} elements. Such links should be uses of the term, with the intent being that the reader can quickly navigate to the term's definition if they're not already aware of it, by clicking on the term's link.
This is shown in the example under Links to definitions below.
Examples
Let's take a look at some examples of various usage scenarios.
Basic identification of a term
This example uses a plain <dfn> element to identify the location of a term within the definition.
HTML
Since the <dfn> element has no title, the text contents of the <dfn> element itself are used as the term being defined.
Result
This looks like this rendered in your browser:
{{EmbedLiveSample("Basic_identification_of_a_term", 650, 120)}}
Links to definitions
To add links to the definitions, you create the link the same way you always do, with the {{HTMLElement("a")}} element.
HTML
Here we see the definition — now with an {{htmlattrxref("id")}} attribute, "definition-dfn", which can be used as the target of a link. Later on, a link is created using <a> with the {{htmlattrxref("href", "a")}} attribute set to "#definition-dfn" to set up the link back to the definition.
Result
The resulting content looks like this:
{{EmbedLiveSample("Links_to_definitions", 650, 300)}}
Using abbreviations and definitions together
In some cases, you may wish to use an abbreviation for a term when defining it. This can be done by using the <dfn> and {{HTMLElement("abbr")}} elements in tandem, like this:
HTML
Note the <abbr> element nested inside the <dfn>. The former establishes that the term is an abbreviation ("HST") and specifies the full term ("Hubble Space Telescope") in its title attribute. The latter indicates that the abbreviated term represents a term being defined.
Result
The output of the above code looks like this:
{{EmbedLiveSample("Using_abbreviations_and_definitions_together", 650, 200)}}
Technical summary
| Content categories | Flow content, phrasing content, palpable content. |
|---|---|
| Permitted content | Phrasing content, but no {{HTMLElement("dfn")}} element must be a descendant. |
| Tag omission | {{no_tag_omission}} |
| Permitted parents | Any element that accepts phrasing content. |
| Implicit ARIA role | term |
| Permitted ARIA roles | Any |
| DOM interface | {{domxref("HTMLElement")}} |
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
Elements related to definition lists: {{HTMLElement("dl")}}, {{HTMLElement("dt")}}, {{HTMLElement("dd")}}
{{HTMLElement("abbr")}}