Skip to main content
WCAGrules
Quick navigation

Declare the page language on the html element

The html element carries a lang attribute naming the page's language, and that one attribute decides how the whole page gets pronounced. W3C lists H57 as sufficient for 3.1.1 Language of Page on its own, with no partner technique, and its test has two parts rather than one. The value has to be a valid BCP 47 tag, and it has to name the language the page is actually written in. So a leftover lang="de" on English copy fails exactly as hard as no attribute at all. It is worth being clear about what this rule is not, because the mistake is common. 3.1.1 is the language declaration and nothing else. Defining unusual words, expanding abbreviations and lowering the reading level are all real obligations, and every one of them belongs to a different criterion at Level AAA. Speech is not the only thing riding on the attribute either. Braille translation software reads it first, to pick the right control codes for accented characters and to stop it forming Grade 2 contractions that were never words.

How we find it in an audit

This is one of the few checks a tool performs correctly from end to end, so a scanner tells us in a second whether the attribute is there. What it will not tell you is whether the value is true. Our reviewers read the page and compare it against the tag. That catches the boilerplate lang="en" sitting on a Spanish landing page, and the template default nobody changed when the site went multilingual.

How affected users experience it

With the wrong language engine every word gets pronounced by the wrong rules, and English read as French phonetics is not accented English, it is noise. The only remedy is switching voices by hand, on every page. And that assumes the listener works out what went wrong at all. Braille readers hit a quieter version of the same problem, where the contractions come out as words nobody wrote and the sentence has to be decoded twice.

Passes vs. fails

Passes: the right voice reads the page. Fails: no lang, so the wrong voice reads it.

Passes

<html lang="en">

Fails

<html>

<!-- and this fails too, on a page written in English -->
<html lang="de">

How this gets tested

The W3C publishes test rules that define what a checker looks for here.

Other ways to satisfy this rule

4 guides on this site are filed under 3.1.1 Language of Page. W3C lists this one as sufficient for that rule on its own. Implement it correctly, in a way your readers' software actually supports, and the rule is met.

This guide is our interpretation of W3C technique H57: Using the language attribute on the HTML element. W3C publishes its techniques as guidance rather than as the standard, and says so on every one of them. The success criterion is what conformance is measured against, and a technique is one documented way to meet it.

Go somewhere useful

Find tools, resources and your workspace.

29 destinations