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 website </ 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 website </ p > </ body > </ html > |
Output: Upon clicking on the above link it will redirect to the following document which is in Spanish: