Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Anchor hreflang Property

Anchor hreflang Property

Anchor Object Reference Anchor Object


Definition and Usage

The hreflang property can set or return the value of the hreflang attribute in a link.

The hreflang attribute can set or return the language code of the linked resource.

Syntax

Set the hreflang attribute:

anchorObject.hreflang="

languagecode

"

Return the hreflang attribute:

anchorObject.hreflang

Value Description
languagecode The language code of the linked resource.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hreflang property.


Example

Example

Returns the language code of the linked resource:

<a id="runoob" hreflang="zh-cn" href="//www.runoob.com/">

Runoob Tutorial

a

<

br

<

script

document.write("Returns the link's hreflang: "); document.write(document.getElementById('runoob').hreflang);

script

The example above produces the following output:

zh-cn

Try it »


Anchor Object Reference Anchor Object