HTML link Tag hreflang Attribute Tutorial

In this section, we will learn what the hreflang attribute is in an HTML <link> element and how to use it.

What is hreflang Attribute in HTML <link> Tag?

The hreflang attribute is used to set the language of the target document that the current document is linking to.

For example, if the target document is written in English, then the value of this attribute would be “en”.

The value of this attribute mainly helps search engines to figure out what the language of the target document is and hence decide if it’s a language matched for queries people of different region and language put in those search engines.

HTML hreflang Attribute in <link> Tag Syntax:

<link hreflang = “language_code”>

<link> Tag hreflang Attribute Values

Depending on the language of the target document, the value we set for the hreflang attribute could be any of the values in the language code reference.

Example: using hreflang attribute in HTML <link> tag

See the Pen using hreflang attribute in HTML <link> tag by Omid Dehghan (@odehghan) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies