X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Link hreflang Property

Link Object Reference Link Object

Example

Return the language code of the linked document:

var x = document.getElementById("myLink").hreflang;

The result of x will be:

ja

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

Internet Explorer Firefox Opera Google Chrome Safari

The hreflang property is supported in all major browsers.


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 Reference Link Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook