Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLElement
  4. lang

HTMLElement: lang property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Thelang property of theHTMLElement interface indicates the base language of an element's attribute values and text content, in the form of aBCP 47 language tag. It reflects the element'slang attribute; thexml:lang attribute does not affect this property.

Note that if thelang attribute is unspecified, the element itself may still inherit the language from its parent. However, that inherited language is not reflected by this property's value.

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

js
// this snippet compares the base language and// redirects to another URL based on languageif (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

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp