Easy Tutorial
❮ Prop Input Time Autofocus Prop Win Sessionstorage ❯

Anchor hreflang Attribute


Definition and Usage

The hreflang attribute sets or returns the value of the hreflang attribute in a link.

The hreflang attribute sets or returns the language code of the linked resource.

Syntax

Set hreflang attribute:

Return hreflang attribute:

Value Description
languagecode The language code of the linked resource

Browser Support

All major browsers support the hreflang attribute.


Example

Return the language code of the linked resource:

<a id="tutorialpro" hreflang="zh-cn" href="//www.tutorialpro.org/">tutorialpro.org</a><br>
<script>
document.write("Return the hreflang of the link: ");
document.write(document.getElementById('tutorialpro').hreflang);
</script>

The above example outputs:

zh-cn

❮ Prop Input Time Autofocus Prop Win Sessionstorage ❯