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:

Expectations

  1. 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:

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).