HTML DOM lang Property
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML DOM lang Property

❮ Element Object

Example

Ge the language code of a <p> element:

var x = document.getElementById("myP").lang;
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.

Common examples are "en" for English, "es" for Spanish, "fr" for France and so on.


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. For more information, look at the Language code reference

Technical Details

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

Related Pages

HTML reference: HTML lang Attribute


❮ Element Object