HTML <link> hreflang Attribute

The a class="code-link" href="/html/hreflang">hreflang attribute on a <link> tag specifies the language and country region of the linked resource. This value is purely advisory.

Example

#

An hreflang attribute on a <link> element.
This link preloads an English language video.

<link rel="preload" as="video" type="video/mp4" 
      href="/media/movie.mp4" hreflang="en" />

Using hreflang

The hreflang attribute specifies the language and country region of the linked resource.

Its value is for advisory purposes only.

The first two characters in the hreflang value represent the language code.

And the last two characters in the hreflang value represents the country code.

For example, the hreflang value of 'en-GB' specifies the English language in Great Britain.

Note: The hreflang attribute requires that href has a value.


Syntax

<link href="URL" hreflang="language_code-country_code" />

Values

#

Value Description
language_code-country_code The first two characters represent the language code of the linked page.
The last two characters represent the country code (optional).

Browser support

Here is when hreflang support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <link>
Guides