The <html> element must have a lang attribute

The html element needs a lang attribute naming the main language of the page, so screen readers, translation tools and browsers process the text correctly.

Rule IDhtml-has-lang
ImpactSerious
Success criterion 3.1.1 Language of Page · A
StandardsWCAG 2.0 · WCAG 2.1 · WCAG 2.2 · Section 508 · EN 301 549
Readabler fix Fixed automatically

Example

Before
<!DOCTYPE html>
<html>
  <head><title>Opening hours – Green Leaf Bakery</title></head>
</html>

A screen reader set to French reads the English page with French pronunciation, which is hard to understand.

After
<!DOCTYPE html>
<html lang="en">
  <head><title>Opening hours – Green Leaf Bakery</title></head>
</html>

The screen reader switches to an English voice and pronounces every word correctly.

Why it matters

Screen readers pick a voice and pronunciation rules from the page language. Without lang, they fall back to the user's default language, so a Spanish speaker browsing an English shop hears English words read with Spanish phonetics. Braille displays use the language to choose the right contraction tables.

The language also helps people with reading difficulties who use text-to-speech tools, lets browsers offer translation, and controls hyphenation, quotation marks and spell-checking. Search engines use it as one of the signals for which audience the page targets.

How to fix it

Add lang to the opening <html> tag with the code of the page's main language:

<html lang="en">

Use a regional variant when it matters for spelling or pronunciation:

<html lang="en-GB">
<html lang="pt-BR">

Multilingual sites. Set the language per page, not once for the whole site. A German page on an English site needs <html lang="de">.

CMS and frameworks. The value usually comes from a setting:

  • WordPress: Settings → General → Site Language, and the theme must print language_attributes().
  • Next.js: set lang on <Html> in _document or on <html> in the root layout.
  • Static site generators: set the language in the site configuration or the base template.

XHTML. Pages served as XML can also have xml:lang, but keep lang too, with the same language.

If a part of the page is in another language, mark it with its own lang attribute, for example <blockquote lang="fr">.

Checklist

  1. Add lang to the <html> element of every page.
  2. Use the code of the page's main language.
  3. Set it per page on multilingual sites.
  4. Mark passages in other languages with their own lang.

How the check works

The check looks at the <html> element of the page. It passes when lang has a non-empty value. It fails when lang is missing or empty, and when only xml:lang is present in an HTML document. Whether the value is a real language code is tested separately, and whether it matches the actual text needs a manual check.

Resources

Updated October 27, 2026