HTML page language is valid

  • Rule Typeatomic
  • Rule ID: bf051a
  • Last modified: Sep 4, 2019
  • Accessibility Requirements Mapping
    • 3.1.1 Language of Page (Level: A)
      • Learn More about 3.1.1 (Language of Page)
      • Required for conformance to WCAG 2.0 and above on level A and above
      • Outcome mapping:
        • Any failed outcomes: not satisfied
        • All passed outcomes: further testing is needed
        • An inapplicable outcome: further testing is needed
  • Input Aspects

Description

This rule checks that the lang and xml:lang attributes of the root element of an HTML page have a valid primary language subtag.

Applicability

The root element of the web page, if it is an html element with a lang and/or xml:lang attribute that is not empty ("").

Note: Documents embedded into other documents, such as through iframe or object elements are not applicable because they are not web pages according to the definition in WCAG.

Expectation

For each test target, the lang and xml:lang attributes have a valid language subtag unless the attribute is empty ("").

Assumptions

There are currently no assumptions

Accessibility Support

There are known combinations of a popular operating system with browsers and assistive technologies that do not support the lang and xml:lang attributes.

While HTML5 specification indicates that xml:lang attribute takes priority over lang attribute, certain assistive technologies prioritise lang over xml:lang instead.

Background

Test Cases

Passed

Passed Example 1

The lang attribute specified has a non-empty value & a valid primary language subtag.

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

Passed Example 2

The xml:lang attribute specified has a non-empty value & a valid primary language subtag.

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

Passed Example 3

The lang and xml:lang attribute specified has a non-empty value & a valid primary language subtag.

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

Passed Example 4

The lang attribute specified has a non-empty value & a valid primary language subtag. The rule checks for the presence of either lang or xml:lang. Empty value specified for the other attribute is ignored.

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

Passed Example 5

The xml:lang attribute specified has a non-empty value & a valid primary language subtag. The rule checks for the presence of either lang or xml:lang. Empty value specified for the other attribute is ignored.

<html lang="" xml:lang="nl"></html>

Failed

Failed Example 1

The lang attribute value is not a valid primary language subtag.

<html lang="xyz"></html>

Failed Example 2

The xml:lang attribute value is not a valid primary language subtag.

<html xml:lang="xyz"></html>

Failed Example 3

Both the lang and xml:lang value specified are not valid values for primary language subtag.

<html xml:lang="xyz" lang="xyz"></html>

Failed Example 4

The lang attribute value has a valid primary language subtag, but a syntactically invalid region subtag.

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

Failed Example 5

The lang attribute value is not a valid primary language subtag.

<html lang="123"></html>

Failed Example 6

The lang attribute value is not a valid primary language subtag.

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

Failed Example 7

The lang attribute value is not a valid primary language subtag.

<html lang=" "></html>

Inapplicable

Inapplicable Example 1

The rule applies to html element and hence usage of lang attribute in svg element is not applicable.

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

Inapplicable Example 2

The rule applies to html element and hence usage of xml:lang attribute in svg element is not applicable.

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

Inapplicable Example 3

An empty value for lang attribute is ignored by this rule, as the applicability specifies only values that are not empty ("").

<html lang=""></html>

Inapplicable Example 4

An empty value for xml:lang attribute is ignored by this rule, as the applicability specifies only values that are not empty ("").

<html xml:lang=""></html>

Glossary

Outcome

key: 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:

  • Inapplicable: No part of the test subject matches the applicability
  • Passed: A test target meets all expectations
  • Failed: A test target does not meet all expectations

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.


Useful Links


Implementations

Tool NameCreated ByReport
AlfaSiteimproveView Report
RGAA 3.0Access42View Report

Acknowledgements