SIA-R6<html> document elements have matching lang and xml:lang attributes (DEPRECATED)

Accessibility requirements

This rule tests conformance of the following accessibility requirements:

Modern screen readers do not rely on the xml:lang attribute anymore, when a lang attribute is given, and discrepancies between these do not cause problem anymore. Therefore this rule has been deprecated and shouldn't be used.

Description

This rule checks that for document elements with both a lang and xml:lang attribute, the primary language subtags of the attributes match.

Applicability

This rule applies to every document element if it is an <html> element in the HTML namespace that:

Expectations

  1. The primary language subtags, if any exist, of the lang and xml:lang attributes are equal.

    HTML requires that the lang and xml:lang attributes match exactly. There is however no known accessibility issue of having mismatching extended language subtags, hence this is permitted by this rule.

Assumptions

This rule makes the following assumption:

  • The lang attribute is being used to conform to WCAG. As such, this rule doesn't test if the attribute is needed to conform to WCAG.

Accessibility support

This rule has the following accessibility support concerns:

Examples

Passed

This <html> element has matching lang and xml:lang attributes:

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

This <html> element has both a lang and xml:lang attribute with matching primary language subtags. This rule does not check the extended language subtags, nor the validity of the values.

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

Failed

This <html> element has non-matching primary language subtags for the lang and xml:lang attributes:

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

Inapplicable

This <html> element has a lang attribute that is only ASCII whitespace, hence has no valid primary language subtag. The rule does therefore not apply:

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

This rule only checks <html> elements, hence this element is not applicable:

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

Acknowledgments

This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/5b7ae0/. Copyright © 2024 W3C® (MIT, ERCIM, Keio, Beihang).