Javascript Reference - HTML DOM lang Property








The lang property sets or gets the language code for an element.

Syntax

HTMLElementObject.lang=language-code

Browser Support

lang Yes Yes Yes Yes Yes

Example

The following code shows how to get the language code for the body element.


<!DOCTYPE html>
<html>
<body id="myid" lang="en-us">
<!--  www .j ava 2 s  .com-->
<script>
    var x=document.getElementsByTagName('body')[0];
    document.write("Body language: " + x.lang);
    document.write("<br/>");
    document.write(document.getElementById('myid').lang);
</script>

</body>
</html>

The code above is rendered as follows: