How to fix “<html> element must have a lang attribute”
By Justin Zagar · Updated
The page doesn't say what language it's written in. Add lang="en" (or your language's code) to the opening html tag, usually by setting the site language in your platform.
- axe rule
html-has-lang(this page also covershtml-lang-valid)- WCAG
- 3.1.1 Language of Page (Level A)
- Lighthouse
- Google Lighthouse and PageSpeed Insights report it as “<html> element does not have a [lang] attribute”
What it means
The lang attribute tells a screen reader which pronunciation rules to use. W3C notes that without it a screen reader may read English text with the wrong voice and accent, which can make it very hard to follow.
The WebAIM Million found 13.5% of home pages missing a document language in 2026. It's one of the easiest fixes on this list: one attribute, set once.
This page also covers axe's html-lang-valid rule, which fails when the attribute is there but holds something that isn't a real language code. Use a code like en, es or en-US.
Who it affects
People who use a screen reader or text to speech, and people who use translation tools.
How to find it
- Run the free checker. If this fails, it fails once for the whole page.
- Or view the page source and look at the first html tag for lang="...".
How to fix it
- Set the site language in your platform's settings, which writes the attribute for you.
- If you edit the template by hand, add the attribute to the html tag.
- If a passage is in another language, mark that element too, like <p lang="es">. That's a separate criterion, 3.1.2, but it's the same idea.
The opening tag
<html><html lang="en">In your website builder
Where each platform’s own help pages cover it, as of November 2026. Menus move, so follow the link if a step doesn’t match what you see.
- WordPress
- Settings > General > Site Language. Most themes print the attribute from this setting through WordPress's language_attributes() function. If yours doesn't, the theme needs a fix. WordPress help
- Squarespace
- On 7.1, open the Site Languages panel and choose the Site language. Squarespace says the choice goes into your site's header code for search engines and accessibility software. Squarespace help
- Wix
- Dashboard > Settings > Language & Region > Site language. The Accessibility Wizard also offers Set main site language. Wix help
- Shopify
- Settings > Languages, then Change default. Shopify warns this deletes existing translations for the language you switch to, so check first. Shopify help
- Webflow
- Localize panel > Locales, then set the Language on the primary locale and save. Webflow help
What a scanner can and can’t tell you
Fixing this clears one automated check. It doesn’t mean the page is accessible, and it doesn’t settle any legal question. Automated tests catch only part of the problems. W3C puts it plainly: evaluation tools “can not determine accessibility, they can only assist in doing so.” The rest takes a person working through the site with a keyboard and a screen reader.
Source: W3C WAI, Selecting Web Accessibility Evaluation Tools. Not legal advice.
Sources
All checked November 8, 2026. The rule wording is axe-core 4.14.0’s own.
Related fixes
- Documents must have <title> element to aid in navigation
Page has no title
- Zooming and scaling must not be disabled
Zoom turned off
- Frames must have an accessible name
Embeds without a title
Check a page for free
Scan any page of your site against WCAG 2.1 AA in about 30 seconds. You get the problems automated testing finds, in plain words, with a link to a fix guide for the common ones.
Rather have someone fix it for you? Tell me about your site.