HTML DOM Element lang

Example

Ge the language code of an element:

let text = element.lang;
Try it Yourself »

Description

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

The lang attribute specifies the element's language code, like "en" for English, "es" for Spanish, or "fr" for French.



Syntax

Return the lang property:

element.lang

Set the lang property:

element.lang = lang_code

Property Value

Value Description
lang_code The value for the element's lang attribute.
See our Full Language Code Reference

Return Value

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

Browser Support

element.lang is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.