Use valid language codes in the `lang` attribute

Content available in English only.

Accessibility isn’t just about avoiding violations — it’s about ensuring that everyone can use your product with confidence. This guide explains each rule’s intent, highlights common issues, and shows how to fix them according to WCAG and the European Accessibility Act (EAA).

These guidelines do not replace the official WCAG standards. They’re concise, developer-focused notes to help you identify and fix issues effectively.

The `lang` value must be a real BCP 47 code, not a spelled-out language name.

Why this matters and how to fix it

Why this matters

Screen readers and translation tools rely on standardized language codes to select the correct voice and pronunciation. Invalid or misspelled codes lead to incorrect speech output, which can make content harder to understand for users who rely on assistive technology.

How to fix this issue

Use valid BCP 47 language codes (e.g., `en`, `en-US`, `sv-SE`, `fr-FR`). Do not use informal values like `english` or `us-en`. If parts of the page contain different languages, apply `lang` on those elements to allow correct voice switching.

Automated detection · Manual review recommended

Developer guidance

This issue relates to invalid or unsupported language codes. Validate all language attributes during development or content reviews, and maintain a shared list of approved locale identifiers. In projects using i18n routing, make sure each route or configuration maps to a valid BCP 47 language code. The GetWCAG scanner flags these issues under the `valid-lang` rule.


Code examples

Incorrect Implementation

<html lang="english">

Correct Implementation

<html lang="en">

Real-World Examples

Before

<p lang="spain">Bienvenidos a nuestra página</p> <!-- 'spain' is not a valid language tag -->

After

<p lang="es-ES">Bienvenidos a nuestra página</p>

CSS Example (Guidance)

/* Adjust font for languages with special characters */
[lang="ja"] {
  font-family: 'Noto Sans JP', sans-serif;
}

[lang="ar"] {
  font-family: 'Noto Sans Arabic', sans-serif;
  direction: rtl;
}

Manual testing

  1. 1. Inspect the <html> element and verify the value of the `lang` attribute.
  2. 2. Check that the code matches a valid BCP 47 language tag.
  3. 3. If the page includes multiple languages, verify each section has its own `lang` attribute.
  4. 4. Test with a screen reader to confirm correct pronunciation and voice switching.
eu icon getwcag

Trusted by organizations across Europe working toward WCAG and EAA conformance