HTMLElement: lang property - Web APIs | MDN (original) (raw)

Value

A string. Common examples include "en" for English, "ja" for Japanese, "es" for Spanish and so on. If unspecified, the value is an empty string.

Examples

// this snippet compares the base language and
// redirects to another URL based on language
if (document.documentElement.lang === "en") {
  window.location.href = "Some_document.html.en";
} else if (document.documentElement.lang === "ru") {
  window.location.href = "Some_document.html.ru";
}

Specifications

Specification
HTML # dom-lang

Browser compatibility