X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor hreflang Property

Anchor Object Reference Anchor Object

Example

Get the language code of a link:

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

The result of x will be:

us-en

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

Internet Explorer Firefox Opera Google Chrome Safari

The hreflang property is supported in all major browsers.


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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook