Latest web development tutorials

HTML DOM Anchor hreflang property

Anchor Object Reference Anchor objects

Definition and Usage

hreflang property sets or returns the value of the link hreflang property.

hreflang property sets or returns the language code of the linked resource.

grammar

Setting hreflang properties:

anchorObject.hreflang="languagecode"

Back hreflang properties:

anchorObject.hreflang

描述
languagecode 被链资源的语言代码


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support hreflang property


Examples

Examples

Returns the language code of the linked resource:

<html>
<body>

<p><a id="w3s" hreflang="us-en"
href="http://www.w3cschool.cc/">W3Schools.com</a></p>

<script>
document.write(document.getElementById("w3s").hreflang);
</script>

</body>
</html>

Examples of the above output:

us-en

try it"


Anchor Object Reference Anchor objects