17.1% of home pages are missing the lang attribute
3.1.1 Language of Page
In Plain Language
Every web page must declare its primary language using the lang attribute on the <html> element. This tells screen readers which language engine and pronunciation rules to use when reading the page aloud.
Without it, a screen reader may try to read French text with English pronunciation rules, making it incomprehensible.
Why It Matters
- Screen readers use the
langattribute to switch between language-specific pronunciation engines -- without it, every word is mangled through the wrong rules. - Browsers use the language declaration for proper text rendering, including hyphenation, quotation marks, and font selection.
- Translation tools rely on the
langattribute to detect the source language before offering translations. - This is a foundational requirement -- simple to implement but still missing on 13.5% of home pages surveyed.
Examples
Do: Declare the page language
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body>...</body>
</html>
Don't: Missing lang attribute
How to Fix It
- Add
langto the<html>element. Use a valid BCP 47 language subtag:enfor English,esfor Spanish,frfor French,zhfor Chinese, etc. - Be specific when needed. Use regional subtags like
en-USvsen-GBwhen pronunciation differences matter for your content. - Mark language changes inline. When a passage is in a different language than the page, use the
langattribute on the containing element:<span lang="fr">bonjour</span>. - Avoid common mistakes. Do not use
lang="javascript",lang="utf-8", or other invalid values. The attribute requires a valid language code, not a programming language or encoding.