<dfn>
HTML <dfn> Tag
The <dfn> tag is used to define the term, that is specified in the context of a definition phrase or sentence. In the browser, the content of the tag is shown in italic.
The <p> tag, the <dt>/<dd> pair, or the <section> tag is considered to be the term’s definition.
The defined term is identified with the following rules:
If <dfn> has a title attribute, the value of this attribute is considered to be the term being defined. The text within the element can be an abbreviation (probably using <abbr>).
If <dfn> has only one child element which is an element with a title attribute, and the <dfn> element doesn’t have its text content, then the precise value of the title of <abbr> will be the term being defined.
If this is not the case, the text content of <dfn> is the term which is being defined.
If an id attribute is included on the <dfn> element, then you can link to this element with <a> elements. Such links help the reader to quickly navigate to the definition of the term by clicking on the link.
Syntax
Syntax
The <dfn> tag comes in pairs. The content is written between the opening (<dfn>) and closing (</dfn>) tags.
Example of the HTML <dfn> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p><dfn>HTML</dfn> (HyperText Markup Language ) — The standardized markup language for documents on the World Wide Web. Most web pages contain a description of the markup in the language HTML</p>
</body>
</html>
Result
In the following example, the value of the title attribute is considered to be the term being defined.
Example of the HTML <dfn> tag with a title attribute:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>Mouse over to see the definition.</p>
<dfn title="HyperText Markup Language">HTML</dfn>
</body>
</html>
Result
Mouse over to see the definition.
HTML
Example of the HTML <dfn> tag with the HTML <abbr> tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>Mouse over to see the definition.</p>
<dfn><abbr title="Cascading Style Sheets">CSS</abbr></dfn>
</body>
</html>
Attributes
Attributes
Attribute | Value | Description |
---|---|---|
title | Specifies the definition of a term (shown when hovering). |
The <dfn> tag also supports the Global Attributes and the Event Attributes.
How to style <dfn> tag? Common properties to alter the visual weight/emphasis/size of text in <dfn> tag:
CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit. CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. CSS font-size property sets the size of the font. CSS font-weight property defines whether the font should be bold or thick. CSS text-transform property controls text case and capitalization. CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.
Coloring text in <dfn> tag:
CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.
Text layout styles for <dfn> tag:
CSS text-indent property specifies the indentation of the first line in a text block. CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user. CSS white-space property specifies how white-space inside an element is handled. CSS word-break property specifies where the lines should be broken.
Other properties worth looking at for <dfn> tag:
CSS text-shadow property adds shadow to text. CSS text-align-last property sets the alignment of the last line of the text. CSS line-height property specifies the height of a line. CSS letter-spacing property defines the spaces between letters/characters in a text. CSS word-spacing property sets the spacing between words.