<html> element must have a
Why it matters
When a web page’s primary language is programmatically identified, browsers and assistive technologies can render the text more accurately; screen readers can use the correct pronunciation; visual browsers can display the correct characters; media players can show captions correctly; and automated translation is enabled.
All users find it easier to understand the page’s content.
How to fix
- Identify the page’s primary language.
- Choose the corresponding a language code from the IANA Language Subtag Registry
- Add a
langattribute to the
<html>element using the correct language tag for the value that represents the primary language of the page.
- If a
langattribute is already specified, make sure its value is spelled correctly.
<html> element doesn't have a
lang attribute, so the browser assumes the primary language is English.
As a consequence, screen readers don't use the correct pronunciation, and users have a hard time understanding the content.
<html> element has a
lang attribute. It correctly identifies the primary language of the page as Spanish.
Screen reader users find the Spanish content easier to understand because it's pronounced correctly.
About this rule
This rule passes if:
<html>element has a
langattribute with a non-empty value.