Open In App

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”. 

Syntax:



<abbr title ="text">Abbreviated form</abbr>

Attribute: This tag accepts an optional attribute as described below:

Example: This example illustrates the use of the <abbr> tag in HTML.






<!DOCTYPE html>
<html>
  
<head>
    <title>abbr tag</title>
</head>
  
<body>
    <h2>Welcome to <abbr 
        title="GeekforGeeks">GFG</abbr>
    </h2>
</body>
  
</html>

Output:

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:

We will understand both ways through the examples.

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. 

Syntax:

<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.




<!DOCTYPE html>
<html>
  
<head>
    <title>abbr tag</title>
</head>
  
<body>
    <h2>GeeksforGeeks</h2>
  
    <p>
        <abbr title="GeekforGeeks">GFG</abbr>:
        A Computer Science portal for geeks.
    </p>
</body>
  
</html>

Output:

Syntax:

<dfn> <abbr title="Expanded form"> Abbreviated form </abbr> </dfn>

Example: This example illustrates the use <abbr> tag with <dfn> tag in HTML.




<!DOCTYPE html>
<html>
  
<head>
    <title>abbr with dfn</title>
</head>
  
<body>
    <h2>
        <dfn> <abbr title="Geeks For Geeks">
            GFG</abbr>
        </dfn>
        : Learn Data Structures Online At 
        Your Own Pace With The Best Of Faculty
        In The Industry.
    </h2>
</body>
  
</html>

Output:

These are the methods that we can use to mark the abbreviations and make them understandable for the user.


Article Tags :