The language (human, not programming) of the page content should be specified in the page so that user agents can figure it out. Where a section of content uses a different language than the page default, it should be specified for that section. This is done via the
lang attribute applied to the element. It lets screen readers load the proper pronunciation rules, and allows visual browsers to display characters more accurately.
3.1.2 Language of Parts: The human language of each passage or phrase in the content can be programmatically determined except for proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the vernacular of the immediately surrounding text. (Level AA)
How to fix:
- HTML pages (pages served as text/html) should use the lang attribute with the proper language value. For example, to mark up a German passage in an otherwise English document
, <p lang="de">Ich bin ein Berliner
- XHTML served as text/html should use both the lang attribute and the xml:lang attribute. For example, to mark up a German passage in an otherwise English document
, <p lang="de" xml:lang="de">Ich bin ein Berliner
- XHTML served as application/xhtml+xml should use the xml:lang attribute only. For example, to mark up a German passage in an otherwise English document
<p xml:lang="de">,Ich bin ein Berliner
- Language tags use a primary code to indicate the language, and optional subcodes (separated by hyphen characters) to indicate variants of the language. For instance, English is indicated with the primary code "en"; British English and American English can be distinguished by using "en-GB" and "en-US", respectively. Use of the primary code is important for this technique. Use of subcodes is optional but may be helpful in certain circumstances.
- The Library of Congress has a list of Codes for the Representation of Names of Languages ; use the values in the ISO 639-1 Code column