SIA-R4<html>
document elements have a lang
attribute
Accessibility requirements
This rule tests conformance of the following accessibility requirements:
Description
This rule checks that document elements have a lang
attribute.
Applicability
This rule applies to every document element if it is an <html>
element in the HTML namespace that:
- is in a top-level browsing context; and
- has a node document with a content type of
text/html
.
Expectations
- The element has a
lang
attribute with a value that is neither empty nor only ASCII whitespace.
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 concern:
<html>
elements within<iframe>
and<object>
elements are not applicable as<iframe>
and<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 emptylang
attributes in nested browsing contexts to also cause accessibility issues.
Examples
Passed
This <html>
element has a lang
attribute that is neither empty nor only ASCII whitespace and therefore passes the rule:
<html lang="en"></html>
Failed
This <html>
element has no lang
attribute and therefore fails the rule:
<html></html>
This <html>
element has a lang
attribute with a value that is empty and therefore fails the rule:
<html lang=""></html>
This <html>
element has a lang
attribute with a value that is only ASCII whitespace and therefore fails the rule:
<html lang=" "></html>
Inapplicable
This document element is not an <html>
element and is therefore inapplicable:
<svg xmlns="http://www.w3.org/2000/svg" lang="en"></svg>
Acknowledgments
This document includes material copied from or derived from https://www.w3.org/WAI/standards-guidelines/act/rules/b5c3f8/. Copyright © 2024 W3C® (MIT, ERCIM, Keio, Beihang).