Accessibility Insights

Back to Info and Examples for Accessibility Insights for Web


An <html> element must have a lang attribute.

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

  1. Identify the page’s primary language.
  2. Choose the corresponding a language code from the IANA Language Subtag Registry
  3. Add a lang attribute to the <html> element using the correct language tag for the value that represents the primary language of the page.
  4. If a lang attribute is already specified, make sure its value is spelled correctly.




The content of a web page is written in Spanish. The <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.


The <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.
<html lang="es">

About this rule

This rule passes if:

  • The <html> element has a lang attribute with a non-empty value.

More examples