On this page:
SeeUnderstanding 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 thelang
orxml:lang
attribute, as appropriate for the HTML or XHTML version you use.
HTML 4.01 uses thelang
attribute on elements. XHTML served as text/html uses thelang
attribute and thexml: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 thexml:lang
attribute on elements.
Note: HTML only offers the use of thelang
attribute, while XHTML 1.0 (as a transitional measure) allows both attributes, and XHTML 1.1 allows onlyxml: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 thexml:lang
attribute defining a quote written in German. This snippet could be included by an XHTML 1.1 document wherelang
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 inHTML 4.01, Inheritance of language codes
For eachlang
attribute in the document:
Check that the value of thelang
attribute conforms toBCP 47: Tags for the Identification of Languages or its successor
For each xml:lang attribute in the document:
Check that the value of thexml:lang
attribute conforms toBCP 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.
This Web page is part ofTechniques and Failures for Web Content Accessibility Guidelines 2.0 (see thelatest version of this document). The entire document is also available as asingle HTML file. See theThe WCAG 2.0 Documents for an explanation of how this document fits in with other Web Content Accessibility Guidelines (WCAG) 2.0 documents. To send public comments, please follow theInstructions for Commenting on WCAG 2.0 Documents.
Copyright © 2016W3C® (MIT,ERCIM,Keio,Beihang). W3Cliability,trademark anddocument use rules apply.