Open In App

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

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.






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




<!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:


Article Tags :