Anchor hreflang Property
Example
Get the language code of a link:
var x = document.getElementById("myAnchor").hreflang;
Try it Yourself »
Definition and Usage
The hreflang property sets or returns the value of the hreflang attribute of a link.
The hreflang attribute specifies the language of a linked document.
Tip: To view all available language codes, go to our Language code reference.
Browser Support
Property | |||||
---|---|---|---|---|---|
hreflang | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the hreflang property:
anchorObject.hreflang
Set the hreflang property:
anchorObject.hreflang = languagecode
Property Values
Value | Description |
---|---|
languagecode | Specifies a two-letter language code that represents the language of the linked document. |
Technical Details
Return Value: | A String, representing the language of the linked document |
---|
More Examples
Example
Change the language code of a link:
document.getElementById("myAnchor").hreflang = "fr";
Try it Yourself »
Related Pages
HTML reference: HTML <a> hreflang attribute
❮ Anchor Object