How to Fix a Missing or Invalid Page Language (html lang)
This check fails when your page's <html> element has no lang attribute, an empty one, or a value that isn't a valid language code, or when any other element on the page uses an invalid lang value. By the end of this guide, every page will declare a correct BCP 47 language code such as en or en-US, and any foreign-language passages will be marked up correctly.

Why it matters
Screen readers such as NVDA, JAWS and VoiceOver use the lang attribute to choose a voice and pronunciation rules. Without it, the reader falls back to the user's default language, so an English page can be read with French phonetics and become hard to understand. Browsers also use it for automatic translation prompts, hyphenation and spell-check, and search engines and AI crawlers treat it as one language signal among several.
2 Language of Parts for inline lang values), so a missing declaration is a baseline accessibility failure.
What you need
Step-by-step fix
Check what your page currently declares
Open the page, press Ctrl+U (Cmd+Option+U on Mac) to view source, and look at the opening <html> tag. Note whether lang is missing, empty (lang=""), or uses an invalid value. Then search the source (Ctrl+F) for lang= to find any other elements with their own lang attribute, because the audit validates those too.
Pick a valid BCP 47 language code
The value must start with a real ISO 639 language subtag, optionally followed by a hyphen and a region. Valid examples:
- en, en-US, en-GB
- fr, fr-CA
- de, es-MX, pt-BR, zh-Hans
Invalid examples that fail the check: english, EN_us, en_US (underscore instead of hyphen), us, or an empty string. Use the language your main content is written in, not the language of your audience or server location.
Add the lang attribute to the <html> element
For static sites or hand-coded templates, edit the shared layout or header file so every page gets the attribute on the root <html> tag. Putting lang on <body> or a wrapper <div> does not satisfy this check; it has to be on <html>. If you have one template per language, set the matching code in each.
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> <title>Example Co</title> </head>
Set it through your CMS or framework
Most platforms generate the <html> tag for you, so change the setting instead of hard-coding it. In WordPress go to Settings → General → Site Language. liquid should output the store locale dynamically.
js App Router, set it in the root layout as shown below. See the platform notes for other systems.
// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}Fix lang values on inline foreign-language content
When a passage, quote or button is in a different language from the page, wrap it with a lang attribute so screen readers switch voice for that part. Every such value must also be a valid code. Language switcher links are a common source of errors: label each link with its own language.
<p>Our motto is <span lang="fr">savoir-faire</span>.</p> <nav aria-label="Language"> <a href="https://example.com/en/" lang="en">English</a> <a href="https://example.com/de/" lang="de">Deutsch</a> <a href="https://example.com/es/" lang="es">Español</a> </nav>
Clear caches and re-test the page
Purge your CMS, plugin and CDN caches so the updated HTML is served. Reload the page, view the source again, and confirm the <html> tag shows the expected value. Then run your audit again, or run axe DevTools or Lighthouse (Accessibility category) in Chrome DevTools, and confirm the html-has-lang, html-lang-valid and valid-lang checks pass.
curl -s https://example.com/ | grep -o '<html[^>]*>'
Platform-specific notes
WordPress
Go to Settings → General → Site Language and save. Themes that call language_attributes() in header.php then output lang automatically (e.g. lang="en-US"). If the attribute is still missing, the theme's header.php has a hard-coded <html> tag; change it to <html <?php language_attributes(); ?>>, ideally in a child theme. With WPML or Polylang, each translation gets its own code.
Shopify
Open Online Store → Themes → ⋯ → Edit code → layout/theme.liquid and make sure the tag reads <html lang="{{ request.locale.iso_code }}">. Online Store 2.0 themes such as Dawn already do this; older or custom themes may hard-code it or omit it. Check checkout and any alternate layout files too.
Next.js
In the App Router, set lang on <html> in app/layout.tsx. In the Pages Router, use <Html lang="en"> in pages/_document.tsx, or configure i18n.locales and i18n.defaultLocale in next.config.js, which makes Next.js set lang per locale automatically.
Wix
Wix generates the <html> tag itself. Set the language under Settings → Language & Region (site language). With Wix Multilingual, each language version gets its own lang value. You cannot edit the <html> tag directly.
Webflow
Webflow outputs lang from the site's primary locale. Set it in Site settings → Localization (primary locale). Secondary locales receive their own lang value on their localized pages. Avoid trying to inject lang via custom code; it won't change the root tag reliably.
Check that it worked
✅ How to verify
- View source or run curl -s https://example.com/ | grep -o '<html[^>]*>' and confirm a valid code like lang="en" or lang="en-US".
- Run Lighthouse (Chrome DevTools → Lighthouse → Accessibility) and confirm '<html> element has a [lang] attribute' and 'has a valid value for its [lang] attribute' pass.
- Use the axe DevTools browser extension to confirm no html-has-lang, html-lang-valid or valid-lang issues remain, including on inline elements.
- Listen to the page with VoiceOver (Cmd+F5 on Mac) or NVDA and confirm it reads with the correct accent and switches voice for marked-up foreign phrases.
⚠️ Common mistakes
- Using an underscore or a full language name, such as en_US or english, instead of a hyphenated BCP 47 code like en-US.
- Putting lang on <body> or a wrapper <div> rather than on the <html> element.
- Hard-coding lang="en" in a shared template on a multilingual site, so German and Spanish pages are announced as English.
- Leaving empty lang="" attributes on inner elements created by page builders or translation plugins, which fails validation.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
Should I use lang="en" or lang="en-US"?
Both are valid and pass the check. Use en if your content isn't region-specific; use en-US or en-GB if spelling and vocabulary follow one region. Screen readers handle both.
Does the html lang attribute affect SEO?
Google says it mostly ignores lang for determining page language and relies on the content itself, and uses hreflang for alternate versions. Bing and other engines, browsers and translation tools do use it, and it's required for accessibility, so set it regardless.
Is lang the same as hreflang?
No. lang on <html> tells software what language the current page is written in. hreflang link tags tell search engines which alternate URLs exist for other languages or regions. Multilingual sites need both.
What lang should I use for a page with mixed languages?
Set the <html> lang to the language of most of the content, then add lang to the elements containing other languages, such as <blockquote lang="es"> or <span lang="ja">.
How to Fix a Missing or Empty Page Title Element
How to Fix Links Without Discernible Text on Your Site
How to Fix Heading Order: One H1 and No Skipped Levels
How to Fix Buttons Without Accessible Names on Your Site
How to Fix a Missing Main Landmark and Unwrapped Content
How to Fix Form Fields Missing Labels for Accessibility