HTML page language is valid

Rule Type:
atomic
Rule ID:
bf051a
Last modified:
March 5, 2020
Accessibility Requirements Mapping
3.1.1 Language of Page (Level A)
  • Required for conformance to WCAG 2.0 and above on level A and above
  • Outcome mapping:
    • Any failed outcomes: success criterion is not satisfied
    • All passed outcomes: success criterion needs further testing
    • An inapplicable outcome: success criterion needs further testing
H57: Using the language attribute on the HTML element
  • Required for conformance to WCAG 2.0 and above on level A and above
  • Outcome mapping:
    • Any failed outcomes: technique is not satisfied
    • All passed outcomes: technique needs further testing
    • An inapplicable outcome: technique needs further testing
Input Aspects
DOM Tree

Description

This rule checks that the lang attribute of the root element of an HTML page has a valid primary language subtag.

Applicability

This rule applies to any document element if it is an html element that:

Note: html elements within iframe and object elements are not applicable as iframe and object elements create nested browsing contexts. These elements can embed any third party content, making testing difficult. As these elements are meant to provide a layer of isolation, the language of the parent browsing context may not be inherited. Thus, embedded documents with an invalid lang attribute can cause accessibility issues. This should be tested separately.

Expectation

For each test target, the lang attribute has a valid language subtag.

Assumptions

Accessibility Support

There are no major accessibility support issues known for this rule.

Background

Test Cases

Passed

Passed Example 1

This html element has a lang attribute whose value is a valid primary language subtag.

<html lang="fr"></html>

Passed Example 2

This html element has a lang attribute value that is a valid language subtag even though the region subtag is not.

<html lang="en-US-GB"></html>

Failed

Failed Example 1

This html element has a lang attribute whose value is not a valid language subtag.

<html lang="em-US"></html>

Failed Example 2

This html element has a lang attribute whose value is not a valid language subtag.

<html lang="#1"></html>

Inapplicable

Inapplicable Example 1

This rule does not apply to svg elements.

<svg xmlns="http://www.w3.org/2000/svg" lang="fr"></svg>

Glossary

Outcome

A conclusion that comes from evaluating an ACT Rule on a test subject or one of its constituent test target. An outcome can be one of the three following types:

Note: A rule has one passed or failed outcome for every test target. When there are no test targets the rule has one inapplicable outcome. This means that each test subject will have one or more outcomes.

Note: Implementers using the EARL10-Schema can express the outcome with the outcome property. In addition to passed, failed and inapplicable, EARL 1.0 also defined an incomplete outcome. While this cannot be the outcome of an ACT Rule when applied in its entirety, it often happens that rules are only partially evaluated. For example, when applicability was automated, but the expectations have to be evaluated manually. Such “interim” results can be expressed with the incomplete outcome.

Valid Language Subtag

A language tag consists of a primary language subtag from the language subtag registry, optionally followed by a hyphen (-) and any sequence of characters.

Note: This definition intentionally differs from the BCP 47 syntax as user agents and assistive technologies are more lenient in what they accept. The definition is however consistent with the behavior of the :lang() pseudo-selector as defined by Selectors Level 3. For example, de-hello would be an accepted way to indicate German in current user agents and assistive technologies, despite not being valid according to BCP 47. As a consequence of this definition, however, grandfathered tags are not correctly recognized as valid language subtags.

Acknowledgements

Authors

Previous Authors

Back to Top