HTML and XHTML
This technique relates to:
Additional subtags for region, script, variant or other aspects may lead to errors in language switching in older versions of some screenreaders.
JAWS 8.0 can be configured to change language automatically on the basis of the lang attribute. However, it only switches amongst major languages as indicated by the primary code. If a regional language variant is indicated with a language subcode, JAWS will use the default variant for which it is configured.
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.
Techniques are informative—that means they are not required. The basis for determining conformance to WCAG 2.0 is the success criteria from the WCAG 2.0 standard—not the techniques. For important information about techniques, please see the Understanding Techniques for WCAG Success Criteria section of Understanding WCAG 2.0.