HTML lang and xml:lang match

  • Rule Typeatomic
  • Rule ID: 5b7ae0
  • Last modified: Aug 21, 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

The rule checks that for the html element, there is no mismatch between the primary language in non-empty lang and xml:lang attributes, if both are used.

Applicability

The root element of the page, if it is an html element with both lang and xml:lang attributes that has a valid language subtag.

Expectation

The value of the primary language subtag (characters before the first dash) for the lang and xml:lang attributes are the same.

Note: HTML 5 specification requires the lang and xml:lang attributes to match exactly. This is not known to impact accessibility, which is why it is permitted in this rule.

Assumptions

  • Although there is no known way that an inappropriate secondary subtag in the lang or xml:lang attribute (such as "en-XYZ") can lead to accessibility issues, it is conceivable that with specific assistive technologies on some languages, there can be exceptions. In that case lang and xml:lang should have matching secondary subtags.

Accessibility Support

Since most assistive technologies will consistently use lang over xml:lang when both are used, violation of this rule may not necessarily be a violation of WCAG 2. Only when there are inconsistencies between assistive technologies, as to which attribute is used to determine the language, does this lead to a violation of SC 3.1.1.

Background

Test Cases

Passed

Passed Example 1

html element with matching value for lang and xml:lang.

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

Passed Example 2

html element with varied case but matching value for lang and xml:lang.

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

Passed Example 3

html element with varied values but matching primary sub-tag value for lang and xml:lang.

<html lang="en" xml:lang="en-GB"></html>

Passed Example 4

html element with varied values but matching primary sub-tag value for lang and xml:lang.

<html lang="en-GB" xml:lang="en"></html>

Passed Example 5

html element with varied values but matching primary sub-tag value for lang and xml:lang, albeit the value XYZ is not valid.

<html lang="en-XYZ" xml:lang="en"></html>

Failed

Failed Example 1

html element with non-matching value for lang and xml:lang.

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

Inapplicable

Inapplicable Example 1

svg element is not applicable for this rule.

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

Inapplicable Example 2

xml:lang is empty, the rule mandates non-empty values.

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

Inapplicable Example 3

Only non-empty values are considered.

<html lang="" 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.


Changelog

Aug 21, 2019fix: update links to WCAG21 resources (#776)
Jul 10, 2019Correct explanatory text of examples (#660)
Jul 9, 2019Bugfix closing svg tag (#657)
May 15, 2019Glossary and Rule update: Replacing "non-empty" definition (#430)
May 9, 2019Chore: Adapt site to ACT Rules CR format (#547)
May 7, 2019Template update - HTML lang and xml:lang match (#511)
Apr 29, 2019chore: rename files and update associations (#489)
Apr 16, 2019chore: add unique id to all rules (#478)
Apr 15, 2019chore: WCAG ACT RULES CG Website Update (#437)
Oct 10, 2018chore: Mark all SVG documents and add missing namespaces (#300)
Oct 9, 2018Fix: testcase generation (#296)
Oct 2, 2018Update name of html-xml-lang-match rule (#279)
Aug 30, 2018Chore: Update test cases format and descriptions (#230)
Jul 13, 2018fix: links in background were not anchors (#187)
Jun 26, 2018FINAL: SC3-1-1-html-xml-lang-match (#96)

Useful Links


Implementations

Tool NameCreated ByReport
AlfaSiteimproveView Report
Axe-coreDeque SystemsView Report
QualWebLASIGE, Faculdade de Ciências da Universidade de LisboaView Report

Acknowledgements