Accessibility Insights

Back to Info and Examples for Accessibility Insights for Web


The lang attribute of an <html> element must have a valid value.

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

Provide a valid lang attribute value:

  1. Identify the page’s primary language.
  2. Choose the corresponding a language code from the IANA Language Subtag Registry
  3. Make sure the value is spelled correctly.




The content of a web page is written in Spanish. The <html> element has the wrong lang attribute for Spanish. As a consequence, screen readers don't use the correct pronunciation, and users struggle to understand the content.
<html lang="sp">


The <html> element has the correct lang attribute. It correctly identifies the primary language of the page as Spanish. Screen reader users find the content easier to understand because it's pronounced correctly.
<html lang="es">

About this rule

This rule passes if:

  • The <html> element’s lang attribute has a valid value

More examples