hreflang

The hreflang attribute indicates the language and regional targeting of a linked document, helping search engines provide relevant content to users.

hreflang Attribute

The hreflang attribute in HTML identifies the language and optional regional targeting of a linked document. It is primarily used within the <link> element inside the <head> section. This attribute assists search engines in recognizing the content's language and intended audience, enhancing search result accuracy based on user language and location.

Syntax

index.html
<a hreflang="language_code">

Values

  • language-code-country-code: The first two characters denote the language of the linked page, while the last two (optional) specify the country.

Definition and Usage

  • The hreflang attribute defines the language of the linked document.
  • It only functions when the href attribute is included.
This attribute serves as a recommendation and does not enforce language settings.

Applies To

The hreflang attribute can be used with the following HTML elements:

Example

The a hreflang attribute
Qarpeo
index.html
<h1>The a hreflang attribute</h1>
<a href="https://institute.qarpeo.com" target="_blank" hreflang="en">Qarpeo</a>

Conclusion

The hreflang attribute is crucial for directing users to the appropriate language version of a webpage. It enhances multilingual SEO by aiding search engines in recognizing language variations and regional targeting, improving accessibility and relevance for global attributes.