Skip to main content
All For Web For All

language

GUIDELINES 3.1.

Overview

Declaring the language of your page and any sections written in a different language allows screen readers to use the correct pronunciation engine, speech rules, and character rendering for that language.

Who is impacted

Users who rely on screen readers, particularly those whose primary language is not English or who visit multilingual sites.

How to test

Inspect the element and verify it has a valid lang attribute set. For any passages in a different language, check that the surrounding element has its own lang attribute with the correct language code.

Resources

Visit W3C Understanding Language of Page and WebAIM Document and Content Language for detailed guidance.

The lang Attribute

Every HTML page should declare its primary language using the lang attribute on the element. For example, an English page should open with . Without this, screen readers may default to the user's system language setting and mispronounce content, making the page difficult or impossible to understand.

Language codes follow the BCP 47 standard. Common examples include en for English, fr for French, es for Spanish, and ja for Japanese. You can also specify regional variants such as en-CA for Canadian English or fr-CA for Canadian French.

Multilingual Content

If a page contains passages written in a different language than the declared page language, wrap those passages in an element with its own lang attribute. For example, a French quote on an English page should be marked up as

. This ensures screen readers switch pronunciation rules for that passage and then return to the page's primary language automatically.