See Understanding Techniques for WCAG Success Criteria for important information about the usage of these informative techniques and how they relate to the normative WCAG 2.0 success criteria. The Applicability section explains the scope of the technique, and the presence of techniques for a specific technology does not imply that the technology can be used in all situations to create content that meets WCAG 2.0.
HTML and XHTML
This technique relates to:
The objective of this technique is to clearly identify any changes in language on a
page by using the lang
or xml:lang
attribute, as appropriate
for the HTML or XHTML version you use.
HTML 4.01 uses the lang
attribute on elements. XHTML served as text/html
uses the lang
attribute and the xml:lang
attribute on
elements, in order to meet the requirements of XHTML and provide backward compatibility
with HTML. XHTML served as application/xhtml+xml uses the xml:lang
attribute on elements.
Note: HTML only offers the use of the lang
attribute, while XHTML 1.0 (as a
transitional measure) allows both attributes, and XHTML 1.1 allows only
xml:lang
.
Allowed values for the lang and xml:lang attributes are indicated in the resources referenced below. 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.
This example demonstrates the use of the xml:lang
attribute defining a
quote written in German. This snippet could be included by an XHTML 1.1 document
where lang
is not allowed.
Example Code:
<blockquote xml: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>
Resources are for information purposes only, no endorsement implied.
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
For each xml:lang attribute in the document:
Check that the value of the xml:lang
attribute conforms to BCP 47: Tags for the
Identification of Languages or its successor
All checks above are true.
If this is a sufficient technique for a success criterion, failing this test procedure does not necessarily mean that the success criterion has not been satisfied in some other way, only that this technique has not been successfully implemented and can not be used to claim conformance.