Skip to content

Tutorial · Accessibility · Beginner · 1 min read

Declare your page language with the lang attribute

A one-attribute fix that changes how screen readers pronounce your content, how browsers translate it and how search engines understand it.

The lang attribute on the html element tells software which human language a page is written in. Without it, a screen reader guesses, and often reads English text with the pronunciation rules of the user's default voice. WCAG 2.2 success criterion 3.1.1, Language of Page, requires it at level A.

The fix

Example
<!doctype html>
<html lang="en-GB">

Use a BCP 47 language tag: a language such as en, de or fr, optionally followed by a region such as GB or US. The tag should match the main language of the content, not the visitor's location.

Why it goes missing at scale

  • Single-page applications render the html element from a static shell that nobody edits.
  • Localised sites set the language on the body or a wrapper instead of on the html element.
  • A static site generator or theme leaves the attribute empty when the language setting is blank.

Mixed-language pages

Mark passages in another language with their own lang attribute, for example a quotation or a product name. This is WCAG success criterion 3.1.2, Language of Parts, at level AA.

Example
<p>Our café motto is <span lang="fr">joie de vivre</span>.</p>

Glossary

BCP 47
The standard format for language tags, such as en-GB or pt-BR.
WCAG
Web Content Accessibility Guidelines, the W3C standard for accessible web content.

Observed in published reviews

Zenith recorded this problem in these company website reviews.