Rules / html rules

html.lang

Default
error
Plugin
html

The <html> element has a valid lang attribute.

Why: Screen readers use lang to read the page aloud with the right voice, and browsers use it to translate and hyphenate. Google does not use it: it reads the language from the visible text. The value is a language tag, such as en or pt-BR, not a locale name, such as en_US.

When off: pages without a language, or with an invalid one, pass.

<!-- ✗ Fails -->
<html></html>
<html lang="en_US"></html>

<!-- ✓ Passes -->
<html lang="en"></html>
<html lang="pt-BR"></html>

References