[lang] attributes have a valid value

Language codes on page elements are valid so screen readers pronounce content correctly.

On this page

Impact

ScanGov impact ratings

About

Specifying a valid [BCP 47 language](https://www.w3.org/International/questions/qa-choosing-language-tags#question) on elements helps ensure that text is pronounced correctly by a screen reader. [Learn how to use the lang attribute](https://dequeuniversity.com/rules/axe/4.10/valid-lang).

Risks

Screen readers mispronounce content, confusing users.

Why it's important

Helps screen readers pronounce content correctly by identifying the language of the page and its elements.

User stories

As a screen reader user, I want the page language to be correctly identified so that content is pronounced properly.

Code

Failing pattern:

<!-- Fail: invalid BCP 47 value -->
<p lang="english">This paragraph is in English.</p>

Passing pattern:

<!-- Pass: valid BCP 47 codes -->
<p lang="en">This paragraph is in English.</p>
<p lang="es">Este párrafo está en español.</p>

Error

ScanGov messaging when a site fails a standard:

Failed: [lang] attributes have a valid value

Guidance

Indicators

On this page