How to specify the language of the document in a given link in HTML5 ?
In HTML5 language of the document in a given link is specified by hreflang attribute. The value (or languageCode) passed here is code of the website language. (for e.g. if the document/website in the given link is in English en is passed as the value).
Below are the examples that illustrates the use of hreflang attribute.
Example 1:
HTML
<!DOCTYPE html><html> <body> <h2>Welcome To GFG</h2> <p>Click <a href= hreflang="en"> here </a>to visit GeeksForGeeks webiste </p> </body> </html> |
Output: Upon clicking on the above link it will redirect to the following document which is in English:

Example 2:
HTML
<!DOCTYPE html><html> <body> <h2>Welcome To GFG</h2> <p>Click <a href= hreflang="es"> here </a> to visit Wikipedia spanish webiste </p></body> </html> |
Output: Upon clicking on the above link it will redirect to the following document which is in Spanish:

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.


