You are here: Reference > JavaScript > client-side > HTML DOM > properties > hreflang (a, link)

hreflang property (a, link)

Browser support:
Sets or retrieves the language of a linked resource or anchor element.

Syntax:

object.hreflang;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: hrefLang

Possible values:

String that sets or retrieves the language code. For more information about language codes click here.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the hrefLang attribute:
<a href="http://www.example.com/" hreflang="en-US" target="_blank">anchor text</a>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the hrefLang property:
<head>
    <script type="text/javascript">
        function GetHrefLang () {
            var anchor = document.getElementById ("myAnchor");
            alert (anchor.hreflang);
        }
    </script>
</head>
<body>
    <a id="myAnchor" href="http://www.example.com/" hreflang="en-US" target="_blank">anchor text</a>
    <button onclick="GetHrefLang ();">Get hrefLang!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content