The lang
property sets or gets the language code for an element.
HTMLElementObject.lang=language-code
lang |
Yes | Yes | Yes | Yes | Yes |
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: