The value of the
lang attribute must be a valid BCP 47 language tag or the empty string (if the language is unknown).
The relevant WCAG 2.0 Success Criteria are:
The related WCAG 2.0 Techniques are:
lang attribute is used to specify the language of element content and attribute text values:
<p lang="en">The content of this element is in English.</p>
<p lang="en" title="The value of this attribute is also in English.">The content of this element is in English.</p>
The language declaration gets inherited:
<div lang="en"> <p>This element contains English content.</p> <p title="This attribute, too.">Same with this element.</p> </div>
You can "overwrite" a language declaration:
<p lang="en">This English sentence contains the German word <span lang="de">Hallo</span>.</p>
You can "overwrite" a parent element's language declaration by introducing any element apart from
script (of HTML 4.0) with an own
<p lang="en" title="An English paragraph"> <span lang="de" title="A German sentence">Hallo Welt!</span> </p>
It’s a good practice to declare the primary language of the document in the
If no other
lang attribute is specified in the document, it means that everything (i.e., element content and attribute text values) is in that language.
If the document contains parts in other languages, these parts should get their own
lang attributes to "overwrite" the language declaration.
It is possible to add the attribute
hreflang to the elements
<area> that create hyperlinks. Such it specifies the language of the linked resource. The language defined must be a valid BCP 47 language tag.
<p> <a href="example.org" hreflang="en">example.org</a> is one of IANA's example domains. </p>