HTML DOM Element lang attribute

Definition and usage

lang The attribute sets or returns the value of the element's lang attribute.

lang The lang attribute specifies the language code of the element, for example "en" represents English, "es" represents Spanish, or "fr" represents French.

Example

Get the language code of the element:

let text = element.lang;

Try it yourself

Syntax

Return the lang attribute:

element.lang

Set the lang attribute:

element.lang = lang_code

Attribute value

Value Description
lang_code

the value of the element's lang attribute.

Please refer to our complete language code reference.

Return value

Type Description
String the value of the element's lang attribute.

Browser support

All browsers support element.lang:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related Pages:

Complete Language Code Reference Manual

HTML lang Attribute