Page Language: Why the html lang Attribute Matters and How to Set It
The lang attribute on the <html> element tells the browser and assistive technology what language a page is written in. A screen reader uses it to pick the right pronunciation rules and voice, so an English page is read with an English voice. Leave it off, or set it wrong, and a screen reader can read your content with the wrong language's pronunciation - intelligible at best, gibberish at worst. WebAIM's 2026 study found a missing document language on 13.5% of home pages. WCAG requires it at Level A (Success Criterion 3.1.1), and it is one attribute to fix.
This is the smallest fix on this site and one of the easiest to forget, because nothing looks wrong. The page renders fine, reads fine to a sighted visitor, and passes a glance. The damage is audible only to someone using a screen reader, when the synthesizer applies French phonetics to English words, or refuses to switch to the user's preferred voice. This page covers what the attribute does, the few ways it goes wrong, and how to set it.
What the lang attribute does
A single attribute on the root element declares the page's language:
<html lang="en">
WCAG Success Criterion 3.1.1 Language of Page, at Level A, requires that "the default human language of each web page can be programmatically determined." The lang attribute is how. As the W3C explains, with the language identified, "screen readers can load the correct pronunciation rules" and render the text accurately. The same attribute also helps browsers offer translation, hyphenate text correctly, and choose appropriate fonts.
The value is a code from the BCP 47 standard - usually a short code like en, es, fr, or de, optionally with a region (en-US, pt-BR). It needs to be the language the page is actually written in.
Who this shuts out
- Screen reader users, directly. The wrong language means the wrong pronunciation engine: English read as if it were Spanish, names and numbers mangled, and the user's chosen voice overridden. For multilingual users who switch voices, a missing or wrong
langbreaks that entirely. - People using browser translation, which leans on the declared language to translate from the right source.
How common is it?
This is another failure our own home-page scan understates - a page's lang is one attribute, and most of the large, professionally-built sites in our State of Web Accessibility 2026 sample set it. The broad measure is WebAIM's, across a million home pages: a missing document language on 13.5% of them. It is common enough to be worth a five-second check on any site.
The few ways it goes wrong
- Missing entirely - no
langon<html>at all. - Wrong language -
lang="en"on a page written in Spanish, so the screen reader uses the wrong pronunciation rules. - Invalid code -
lang="english"or a made-up value instead of the validen. An invalid code fails the same criterion as a missing one. - Unmarked language changes - a quote or phrase in another language with no
langon it, so it is read in the page's main language.
How to fix it
- Add
langto<html>-<html lang="en">. One place, whole page. - Use a valid BCP 47 code -
en,es,fr,de, optionally with a region. Not "english". - Match the code to the content - the language the page is actually in.
- Mark in-page language changes -
<span lang="es">...</span>for a foreign word or passage. - Re-test - confirm the attribute is present and valid, and listen if you can.
What a scan can and cannot tell you
A scan reliably catches a missing or invalid lang attribute, because both are facts about the markup. The one thing it cannot judge is whether the declared language is the right one - lang="en" on a Spanish page passes the automated check but fails the user, so a person confirms the code matches the content. We report the automated slice; that confirmation is part of a full audit.
Common questions
What does html lang do? It declares the page's language so a screen reader uses the right pronunciation and voice.
What is the correct value? A valid BCP 47 code - en, es, fr, optionally with a region like en-US. Not "english".
Does missing lang fail WCAG? Yes - it fails 3.1.1 (Level A).
Multiple languages? Set <html lang> to the main language and mark other-language passages with their own lang.
Check your own site
Run a free check on your home page and it will confirm in about a minute whether your lang attribute is present and valid. For the whole site, a full audit checks it everywhere and confirms the language matches the content, and monitoring catches it if a template change drops the attribute. For the data behind our research, read the State of Web Accessibility 2026.