Anchor hreflang Attribute
Definition and Usage
hreflang
The attribute sets or returns the language of the link hreflang Attribute value.
hreflang
The attribute specifies the language of the linked document.
Tip:To view all available language codes, please visit ourLanguage Code Reference Manual.
Example
Example 1
Get the language code of the link:
var x = document.getElementById("myAnchor").hreflang;
Example 2
Change the language code of the link:
document.getElementById("myAnchor").hreflang = "fr";
Syntax
Return the hreflang attribute:
anchorObject.hreflang
Set the hreflang attribute:
anchorObject.hreflang = languagecode
Attribute Value
Value | Description |
---|---|
languagecode | A two-letter language code that specifies the language of the linked document. |
Technical Details
Return Value: | A string value that indicates the language of the linked document. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <a> hreflang Attribute