Anchor hreflang Property
Anchor Object
Definition and Usage
The hreflang property can set or return the value of the hreflang attribute in a link.
The hreflang attribute can set or return the language code of the linked resource.
Syntax
Set the hreflang attribute:
anchorObject.hreflang="
languagecode
"
Return the hreflang attribute:
anchorObject.hreflang
| Value | Description |
|---|---|
| languagecode | The language code of the linked resource. |
Browser support





All major browsers support the hreflang property.
Example
Example
Returns the language code of the linked resource:
<a id="runoob" hreflang="zh-cn" href="//www.runoob.com/">Runoob Tutorial
a
<
br
<
scriptdocument.write("Returns the link's hreflang: "); document.write(document.getElementById('runoob').hreflang);
script
The example above produces the following output:
zh-cn
Try it »
Anchor Object