The <dfn> HTML tag is known as a phrase tag, it is mainly used to style text. By default it makes text italic to illustrate that the tag text is a definition. It works equally as well in table based layouts as well as CSS based ones. As with all phrase based HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <dfn> tag it is displayed as a definition text.
<dfn>Some definition text in here</dfn>
Any text between the opening and closing tag will be displayed as a definition text.
It is possible to style and add functionality to the <dfn> tag, this is done by adding an attribute to after the p in the opening <dfn> tag
Attributes allowed for the <dfn>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<dfn id=”header”>Some definition text</dfn>
With all attributes there is a space after the initial p then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <dfn> tag may use either the id or class as an atribute.
The attribute style allows you to include css style information for a single <dfn> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
<dfn>Some definition text</dfn> – basic usage example.
<dfn id=”header>Some definition text</dfn> – definition text which is styled by the id header.
<dfn class=”headerclass”> Some definition text </dfn> – definition text which is styled by the class headerclass.
<dfn id =”header” class=”headerclass”> Some definition text </dfn> – definition text which is styled by the class headerclass and the id header.
<dfn style="color:#F00">Some definition text</dfn> – definition text which has a custom colour of red.
<dfn dir="rtl">Some definition text</dfn> – definition text where the text reads from right to left.
<dfn lang="uk">Some definition text</dfn> – definition text where the language has been tagged as UK.
<dfn title="ptitle">Some definition text</dfn> – definition text where the tag has been titled ptitle.
Touching on just the surface of the <dfn> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.