<html> document elements have matching
This rule tests conformance of the following accessibility requirements:
- is in a top-level browsing context; and
- has a
langattribute that has a valid primary language subtag; and
- has an
This rule makes the following assumption:
langattribute is being used to conform to WCAG. As such, this rule doesn't test if the attribute is needed to conform to WCAG.
This rule has the following accessibility support concerns:
<object>elements are not applicable as
<object>elements create nested browsing contexts. However, as these elements are meant to provide a layer of isolation, the declared language of their parent browsing context will likely not be inherited, making it possible for non-valid
langattributes in nested browsing contexts to also cause accessibility issues.
Having matching primary language subtags of the
xml:langattribute, but non-matching language tags overall, will not cause accessibility issues unless there's a sufficiently large difference between the two language tags. One notable case is the language tags for Cantonese (
zh-que) and Mandarin (
zh-cmn) where the primary language subtags match, but the extended language subtags don't. Such a case would not fail this rule, but could lead to accessibility issues in practice.
<html lang="en" xml:lang="en"></html>
<html lang="en-GB" xml:lang="en-XYZ"></html>
<html lang="en" xml:lang="fr"></html>
<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>
This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/5b7ae0/. Copyright © 2023 W3C® (MIT, ERCIM, Keio, Beihang).