Technique H58:Using language attributes to identify changes in the human language
Applicability
HTML
This technique relates to 3.1.2: Language of Parts (Sufficient).
Description
The objective of this technique is to clearly identify any changes in language on
a page by using the lang
attribute.
Allowed values for the lang attribute are indicated in the resources referenced below. Language tags use a primary code to indicate the language, and optional sub-codes (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.
Examples
Example 1
This example demonstrates the use of the lang
attribute to define a quote written in German.
<blockquote lang="de"> <p> Da dachte der Herr daran, ihn aus dem Futter zu schaffen, aber der Esel merkte, daß kein guter Wind wehte, lief fort und machte sich auf den Weg nach Bremen: dort, meinte er, könnte er ja Stadtmusikant werden. </p> </blockquote>
Other sources
No endorsement implied.
Tests
Procedure
For each element in the document:
- Check that the human language of the content of the element is the same as the inherited language for the element as specified in HTML 4.01, Inheritance of language codes
For each lang
attribute in the document:
- Check that the value of the
lang
attribute conforms to BCP 47: Tags for the Identification of Languages or its successor - Check that the language code matches the language of the content it applies to.
Expected Results
- All checks above are true.