Link hreflang Property
Example
Return the language code of the linked document:
var x = document.getElementById("myLink").hreflang;
Try it Yourself »
Definition and Usage
The hreflang property sets or returns the language code of the linked document.
The hreflang attribute does not render as anything special in any of the major browsers. However, it can be used by search engines, or in scripts.
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:
linkObject.hreflang
Set the hreflang property:
linkObject.hreflang = languagecode
Property Values
Value | Description |
---|---|
languagecode | Specifies the language code of the linked document |
Technical Details
Return Value: | A String, representing the language code of the linked document |
---|
More Examples
Example
Change the language code of the linked document:
document.getElementById("myLink").hreflang = "en-us";
Try it Yourself »
Related Pages
HTML reference: HTML <link> hreflang attribute
❮ Link Object