AccessLens

How to fix: “<html> element must have a lang attribute”

Page language not set, explained in plain English, with the exact fix and code you can copy.

Scanner rule:
html-has-lang
Standard:
WCAG 3.1.1 Language of Page (Level A)

What this error means

The opening <html> tag should say what language the page is written in. Screen readers use it to pick the right voice and pronunciation. Without it, an English page may be read with the wrong accent, or a French page read as if it were English, which makes it hard to understand.

A missing document language was found on 13.5% of home pages in the WebAIM Million 2026 report. Source: WebAIM Million

Who it affects

Screen reader users, and anyone using browser translation tools, which also use this attribute to decide whether a page needs translating.

Where it usually hides

  • Hand-built sites and older templates that never included it
  • Custom themes and landing-page tools
  • Sites in several languages where only some pages set it

How to fix it

  1. Open the page's HTML and find the opening <html> tag.
  2. Add lang with the right language code: lang="en" for English, lang="es" for Spanish, lang="fr" for French. A regional form such as en-US is also valid.
  3. If part of a page is in another language, mark that part with its own lang attribute, for example <span lang="fr">bonjour</span>.
  4. On multilingual sites, make sure each language version sets its own code.

Before and after

Before

<html>

No language declared.

After

<html lang="en">

English declared; this is the whole fix.

On your website platform

WordPress

WordPress sets the lang attribute from the Site Language option under Settings, then General. If it is missing, the theme is probably not calling the language_attributes() function in its header.

Shopify

Themes such as Dawn set it with lang="{{ request.locale.iso_code }}" in theme.liquid. If your theme omits it, add that to the html tag.

Common mistakes

  • Using a country name or a made-up code, such as lang="english". It must be a valid language code like 'en'.
  • Setting the language on the body instead of the html tag.

How to check your fix

  • Re-run a scan to confirm the error is gone.
  • In Chrome, right-click the page, choose View Page Source, and check the first few lines.

Is this on your site?

Run a free scan and see every page and element affected. No account needed.

Questions people ask

Which language code do I use?

Use the two-letter ISO 639-1 code for your page's main language, such as en, es or fr. You can add a region, for example en-GB.

Does this affect SEO?

Setting the language correctly also helps search engines and translation tools understand the page, so it is useful beyond accessibility.

Keep reading

Automated scans catch only part of what WCAG covers, and fixing a scan result is not a legal guarantee of compliance. Last reviewed November 16, 2026.