HTML DOM lang Property
Complete Body Object Reference
Definition and Usage
The lang property sets or returns the language code for the element.
Syntax
bodyObject.lang=language-code
|
Example
The following example shows two methods on how to get the language code for the <body>
element:
<html>
<body id="myid" lang="en-us">
<script type="text/javascript">
x=document.getElementsByTagName('body')[0];
document.write("Body language: " + x.lang);
document.write("<br />");
document.write("An alternate way: ");
document.write(document.getElementById('myid').lang);
</script>
</body>
</html>
|
Output:
Body language: en-us
An alternate way: en-us
|
Try-It-Yourself Demos
Return the
language code for the <body> element
Complete Body Object Reference
|
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|