How to mark abbreviations and make them understandable in HTML ?
In this article, we will learn how to specify a shorter version of the content in HTML. The <abbr> tag (Abbreviation) is used to define the abbreviation or short form of an element. The <abbr> and <acronym> tags are used as shortened versions and used to represent a series of letters. For instance, “HTML” is used as an abbreviation for “HyperText Markup Language”.
<abbr title ="text">Abbreviated form</abbr>
Attribute: This tag accepts an optional attribute as described below:
- title: It is used to specify extra information about the element. When the mouse moves over the element then it shows the information.
Example: This example illustrates the use of the <abbr> tag in HTML.
Using <abbr> tag simply won’t show the expansion of the abbreviation even if the mouse has hovered over it. This makes it difficult for the user to understand the abbreviated form.
There are two ways using which we can make abbreviation understandable:
- using <abbr> with title attribute
- using <abbr> with<dfn>
We will understand both ways through the examples.
- <abbr> with title attribute:
In order to remove this problem, the <abbr> tag is used in combination with the title attribute which provides an expansion for the abbreviation. This text is provided by the browser as a tooltip when the mouse pointer has hovered over the element.
<abbr title="expanded form"> abbreviated form </abbr>
Example: In this example, we have used the title attribute inside the <abbr> tag that specify extra information about the element.
- <abbr> with<dfn>: < abbr>can be used with <dfn> to add definition for an abbreviation.
<dfn> <abbr title="Expanded form"> Abbreviated form </abbr> </dfn>
Example: This example illustrates the use <abbr> tag with <dfn> tag in HTML.
These are the methods that we can use to mark the abbreviations and make them understandable for the user.