HTML Global lang Attribute

❮ Previous Global Attributes Next ❯

Example

<h2>Catalan</h2>
<p lang="ca"><bdi>Català</bdi></p>

<h2>German</h2>
<p lang="de"><bdi>Deutsch</bdi></p>

<h2>Spanish</h2>
<p lang="es"><bdi>Español</bdi></p>

<h2>French</h2>
<p lang="fr"><bdi>Français</bdi></p>

Meaning

The lang attribute specifies the language being used for the enclosed content.

The language is identified using the ISO standard language abbreviations, such as en for English, en fr French, and so on.

The 3 most common subtags are:

  1. Language subtag

    Required. A 2-or-3-character code that defines the basic language, typically written in all lowercase. For example, the language code for English is en, and the code for French is fr.

  2. Script subtag

    Optional. This subtag defines the writing system used for the language, and is always 4 characters long, with the first letter capitalized. For example, French-in-Braille is fr-Brai and ja-Kana is Japanese written with the Katakana alphabet. If the language is written in a highly typical way, like English in the Latin alphabet, there is no need to use this subtag.

  3. Region subtag

    Optional. This subtag defines a dialect of the base language from a particular location, and is either 2 letters in ALLCAPS matching a country code, or 3 numbers matching a non-country area. For example, es-ES is for Spanish as spoken in Spain, and es-013 is Spanish as spoken in Central America. “International Spanish” would just be es.




Standard Syntax

<element lang="languageCode">



Browser Support




Status







Attribute Values

Value Description
languageCode Specifies the language code for the element's content. For this purpose lang or hreflang language attributes are generally used.
See all the language codes here.
❮ Previous Global Attributes Next ❯