HTML hreflang Attribute

Last Updated : 31 Jul, 2026

HTML hreflang Attribute is used to specify the language for a linked document. It is used only when the href attribute is set. 

Syntax

<element hreflang="language_code"> 

Attribute Value

The hreflang attribute contains a single value language_code which is the two-letter language code and used to specify the language of the linked document e.i. en for English, hi for Hindi, etc.

Supported Tags: <a>,<area> and <link>

Examples of HTML hreflang Attribute

Example 1: the This Example illustrates the use of hreflang attribute in anchor element.  

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML hreflang Attribute
    </title>
</head>

<body>
    <center>
        <h1>
            GeeksForGeeks
        </h1>
        <h2>
            HTML <a> hreflang Attribute
        </h2>

<!--Driver Code Ends-->

        <p>Welcome to
            <a href=
"http://www.example.com:4097/test.htm#part2" 
               id="GFG" 
               rel="nofollow" 
               hreflang="en-us" 
               target="_self">
                GeeksforGeeks
            </a>
        </p>

<!--Driver Code Starts-->
    </center>
</body>

</html>
<!--Driver Code Ends-->

 Example 2: This Example illustrates the use of hreflang attribute in area element.  

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML area hreflang Attribute
    </title>
</head>

<body style="text-align:center;">
    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165729/area11.png" 
         alt="alt_attribute" 
         width="300" 
         height="119" 
         class="aligncenter" 
         usemap="#shapemap" />

<!--Driver Code Ends-->

    <map name="shapemap">
        <!-- area tag contained image. -->
        <area shape="poly" 
              coords="59, 31, 28, 83, 91, 83" 
              href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165802/area2.png" 
              alt="Triangle" 
              hreflang="en">

        <area shape="circle" 
              coords="155, 56, 26" 
              href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165934/area3.png" 
              alt="Circle" 
              hreflang="en">

        <area shape="rect" 
              coords="224, 30, 276, 82" 
              href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227170021/area4.png" 
              alt="Square" 
              hreflang="en">
    </map>

<!--Driver Code Starts-->
</body>

</html>
<!--Driver Code Ends-->
Comment