Open In App

How to specify the language of the document in a given link in HTML5 ?

Improve
Improve
Like Article
Like
Save
Share
Report

In the HTML5 language of the document, a given link is specified by hreflang attribute. The value (or languageCode) passed here is the code of the website language. (e.g., if the document/website in the given link is in English en is passed as the value).

Example 1: Below is the example that illustrates the use of the hreflang attribute.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h2>Welcome To GFG</h2>
    <p>Click
        <a href="https://www.geeksforgeeks.org/" hreflang="en">
            here
        </a>to visit GeeksForGeeks website
    </p>
</body>
</html>


Output: Upon clicking on the above link it will redirect to the following document which is in English: 

Example 2: In this example, we will use hreflang for the Spanish language.

HTML




<!DOCTYPE html>
<html>
   
<body>
    <h2>Welcome To GFG</h2>
    <p>Click
        <a href=
           hreflang="es">
            here
        </a>
        to visit Wikipedia spanish website
    </p>
</body>
</html>


Output:  Upon clicking on the above link it will redirect to the following document which is in Spanish:



Last Updated : 06 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads