Missing Lang Attribute
The lang attribute on the <html> element declares the primary language of the page. Screen readers use it to select the correct pronunciation rules. Browser translation features use it to determine the source language. Search engines use it for language-specific results.
How common is this error?
We ran this validator over the home page of the Tranco top 5,000 websites in August 2026. 251 of the 2,656 sites we could reach hit it. That makes it the 13th most common HTML problem we found, across 253 occurrences. See the full study.
Most frequent wording: The <html> element has no "lang" attribute. It is valid HTML, but it leaves the page language undeclared, which fails WCAG 3.1.1.
Why It Matters
Without the lang attribute, screen readers may use the wrong pronunciation (reading French text with English rules), browser auto-translate features won't work correctly, and search engines may serve your page for the wrong language queries.
Common Causes
- Starting from a bare <html> tag without setting the language.
- Using a boilerplate or generator that omits lang.
- Serving multilingual content from one template that never sets the per-page language.
Code Examples
<html> <head>...</head> <body>...</body> </html>
<html lang="en"> <head>...</head> <body>...</body> </html>
How to Fix
- 1Add lang="en" (or appropriate code) to your <html> element.
- 2Use standard BCP 47 language codes: en, fr, de, es, zh, ja, etc.
- 3For mixed-language content, use lang on specific elements: <p lang="fr">Bonjour</p>.
- 4For regional variants, use subtags: lang="en-US", lang="pt-BR".
Frequently Asked Questions
Where exactly does the lang attribute go?
What value should I use for lang?
Does the lang attribute affect SEO?
Check Your HTML Now
Our validator detects this error automatically and shows the exact line number.
Open HTML ValidatorRelated HTML Errors
Missing DOCTYPE Declaration
A missing DOCTYPE forces browsers into quirks mode, breaking your layout. Learn why <!DOCTYPE html> is required and how to fix inconsistent rendering fast.
Missing Viewport Meta Tag
Without a viewport meta tag, your site looks tiny on mobile even with perfect CSS. Learn the correct viewport configuration to fix responsive rendering fast.
Missing Charset Declaration
A missing charset declaration turns accents and emoji into garbled text. Learn why declaring UTF-8 is essential and how to fix encoding issues in your HTML.