HTML DOM lang Property

HTMLElement Object Reference Element Object

Example

Ge the language code of a <p> element:

var x = document.getElementById("myP").lang;

The result of x will be:

en

Try it yourself »

Definition and Usage

The lang property sets or returns the value of the lang attribute of an element.

The lang attribute specifies the language code of the element's content.


Browser Support

Property
lang Yes Yes Yes Yes Yes

Syntax

Return the lang property:

HTMLElementObject.lang

Set the lang property:

HTMLElementObject.lang=language_code

Property Values

Value Description
language_code Specifies the language code for the element's content. Language code reference

Technical Details

Return Value: A String, representing the language of the element's text

Related Pages

HTML reference: HTML lang Attribute


HTMLElement Object Reference Element Object


SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: