HTML Lang Attribute: Language Declaration for Accessibility
Open a French help page and you might see French headings, instructions, and buttons. Inspect its HTML, though, and you may find <html lang="en"> left over from the English template. Nothing looks wrong on screen, but a screen reader may pronounce the French instructions using English pronunciation rules.
Set the lang attribute on the root <html> element to the primary language of the page the visitor is reading. When a passage uses a different language, set lang on the element containing that passage. These two decisions address different accessibility needs, and checking only that an attribute exists can miss errors in both.
How the HTML lang attribute works

The lang attribute identifies the language of an element’s content. Its value applies to the elements inside it unless one declares a different language. Setting it on <html> gives the whole document a default, including the page title. Setting it only on <body> leaves the title outside that declaration.
<html lang="fr">
<head>
<title>Centre d’aide</title>
</head>
<body>
<h1>Comment pouvons-nous vous aider ?</h1>
</body>
</html>Here, both the title and the heading inherit French. Assistive technology can use that information to select an appropriate voice or pronunciation rules. The result depends on the reader’s settings and installed voices. The declaration identifies the language; it does not translate the text or force a particular voice.
What WCAG 2.2 asks you to declare
For a WCAG 2.2 accessibility review, distinguish the default language of the document from language changes within it:
- 3.1.1 Language of Page (Level A): The default human language of each page must be programmatically determinable. On an HTML page, a correct
langvalue on the root element provides that information. - 3.1.2 Language of Parts (Level AA): The language of a passage or phrase must also be programmatically determinable when it differs from the surrounding content. Exceptions include proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the surrounding language.
An English article does not need a language change every time it mentions a French company by name. But if it quotes that company’s returns instructions in French, mark the quotation. A page can have the right default language and still need work on the language of its parts.
Choose a language tag that matches the content

Use a BCP 47 language tag such as en for English, fr for French, or ar for Arabic. A language alone is often sufficient. Add a region or script subtag when the distinction describes the content: for example, pt-BR for Brazilian Portuguese or zh-Hant for Chinese written in traditional characters.
Choose the tag from the published text, not the visitor’s location. An English-language privacy notice for customers in France is still English. Conversely, a French notice on an otherwise English site should declare French as its page language.
Watch the handoff from the CMS to HTML. A publishing system might store a locale as en_US, but the corresponding HTML language tag is en-US, with a hyphen. If the CMS falls back to English because a translation is unavailable, declare English for the fallback page rather than copying the language requested in the URL.
Mark multilingual passages at the right level
Place the language change on the smallest element that contains the whole passage. For a translated link label inside an English sentence, that may be the link itself. For a French quotation spanning several paragraphs, set the attribute once on the enclosing quotation.
<p>Read our privacy notice in French:
<a href="#notice-fr" lang="fr">Avis de confidentialité</a>.
</p>
<section id="notice-fr" lang="fr">
<h2>Avis de confidentialité</h2>
<p>Voici comment nous utilisons vos données.</p>
</section>In this example, a reader can encounter the French link label with the appropriate language information before following it. The destination section declares French separately because it does not inherit language from a link pointing to it. English content after the section continues to inherit the document default.
The same principle applies to consent dialogs and account menus. If a French dialog appears over an English page, mark the dialog as French. Changing the root language instead would incorrectly relabel the English page behind it. If the visitor switches the entire interface to French, update the root declaration as part of that switch.
Test language declarations before release

A useful HTML lang attribute accessibility check asks two questions: Can software identify the declared language? And is that the language of the content? An automated check can flag a missing or invalid value. A valid lang="en" on a French page is a different problem: the markup is plausible, so someone needs to compare it with what was published.
- Select representative pages and states. Include a default-language page, a translated page, a fallback page, and a shared component such as a consent dialog. Include a language switch without a full reload if your application supports one.
- Inspect the rendered root element. In browser developer tools, find
<html>and compare itslangvalue with the title, headings, and main text. Repeat after switching languages and after navigating back. Looking only at the initial source can miss stale values after navigation. - Follow inheritance through mixed-language content. Inspect a translated passage, its enclosing element, and the content immediately after it. Check that the override covers the whole passage without extending to unrelated text.
- Listen to a meaningful transition. With appropriate voices installed and automatic language switching enabled, use a screen reader to read from the default language into the passage and back out. If pronunciation sounds unexpected, inspect the markup as well as the voice settings before assigning a defect.
- Record the failure where it can be fixed. Note the page or route, how you reached it, the expected language, and the rendered value. A root value that stays English across translated routes points the team toward the shared template or routing logic; one unmarked quotation calls for an editorial fix.
For example, a useful defect report reads: “After switching the help page from English to French, the heading and body change to French, but the root remains lang="en". Expected lang="fr".” That gives the developer both a reproducible state and a concrete acceptance test.
Keep language checks in your accessibility workflow
Give template owners responsibility for the root declaration and give editors a way to mark passages in another language. Retest both when you add a locale, change a translation fallback, or replace a shared dialog. Fixing one page manually is unlikely to last if the publishing template still emits the wrong value.
Corpowid combines AI accessibility auditing, ongoing monitoring, and exportable reporting with cookie consent and legal document management. If translated notices or consent interfaces are part of your review, request an accessibility audit and identify the language routes and visitor states you want examined. Pair automated findings with a manual review of the published wording and screen reader behavior.
Frequently asked questions
Is hreflang a substitute for the HTML lang attribute?
No. The hreflang attribute describes the language of a linked resource, such as an alternate version of a page. It does not declare the language of the current document or of the link text. Use lang for those declarations.
Does lang set the reading direction for Arabic or Hebrew?
No. Language and text direction are separate. For a page written primarily in Arabic, for example, <html lang="ar" dir="rtl"> identifies Arabic and sets the document’s base direction to right-to-left.
Should a bilingual page list two languages in the root attribute?
No. Use one language tag for the document default, then mark the sections written in the other language. A comma-separated value such as lang="en, fr" is not a valid way to declare a bilingual page.