HTML <a> hreflang attribute

Definition and Usage

hreflang attribute specifies the language of the linked document.

Only when set href attribute use this attribute only when

Note:This attribute is purely advisory.

Detailed Explanation

the href attribute is used. hreflang attribute. It can only be specified when lang attribute similarly,hreflang The value of the attribute is also a double-character language code of the ISO standard. Unlike the lang attribute,hreflang The attribute does not specify the language used in the content of the tag, but specifies the language used in the document called by the href attribute.

Example

The hreflang attribute specifies the language of the linked document:

<a href="https://www.codew3c.com" hreflang="zh">W3School</a>

Try It Yourself

Syntax

<a hreflang="language_code">

Attribute Value

Value Description
language_code

Two-letter language codes specify the language of the linked document.

To view all available language codes, please visit ourLanguage Code Reference Manual.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support