Skip to content

Technique H58:Using language attributes to identify changes in the human language

About this Technique

This technique relates to 3.1.2: Language of Parts (Sufficient).

This technique applies to HTML.

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 sub-codes is optional but may be helpful in certain circumstances.

Examples

Example 1: 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>

Related Resources

No endorsement implied.

Tests

Procedure

For each element in the document:

  1. 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 - The lang and xml:lang attributes.

For each lang attribute in the document:

  1. Check that the value of the lang attribute conforms to BCP 47: Tags for Identifying Languages; Matching of Language Tags or its successor.
  2. Check that the language code matches the language of the content it applies to.

Expected Results

  • All checks above are true.

Test Rules

The following are Test Rules related to this Technique. It is not necessary to use these particular Test Rules to check for conformance with WCAG, but they are defined and approved test methods. For information on using Test Rules, see Understanding Test Rules for WCAG Success Criteria.

Back to Top