Page language code not valid
What it is
The lang attribute on the page’s <html> tag has a value, but it is not shaped like a language code. A well-formed code usually begins with the language in two or three letters, optionally followed by parts such as a script or region, each after a hyphen: en, en-GB, pt-BR, zh-Hant. Typical mistakes are a language name (english), an underscore (en_US) or a stray character.
Why it matters
Assistive technology may not recognise a malformed code and then treats the page much as if no language were declared, so a screen reader can keep its default voice and mispronounce the text. MDN notes that browsers treat a value that is not a valid BCP 47 tag as an invalid language. A page language that cannot be determined fails WCAG 3.1.1 Language of Page (Level A), which the European Accessibility Act has required many businesses selling to consumers online in the EU to meet since June 2025.
How Asky checks it
Asky reads the page’s raw HTML and tests the lang value on the <html> tag, trimmed, against a simple shape: two or three letters, then any number of parts of one to eight letters or digits, each after a hyphen. Tags starting x- or i- (private use) also pass. Letter case does not matter. The page is reported when the value does not fit, so en_US, english and en--US are reported. Codes are not looked up in the language registry, so a well-shaped but unknown code such as xx passes, and the code is not compared with the page’s text. A missing or empty value is reported as page language not declared instead.
Reported as a warning with medium severity.
How to fix it
- Read the value shown in the issue and replace it with the correct code, using a hyphen, not an underscore:
en_USbecomesen-US,englishbecomesen. The W3C guide to choosing a language tag lists the parts. - Keep it short. The language alone (
de) is enough; add a region only when the page is written for one (de-CH). - If a template, theme or plugin writes the value, fix it there so every page is corrected.
- Check that the code names the language the page is actually written in. Asky does not compare them, but screen readers rely on it.
Example
https://example.com/blog/pricing-guide is written in American English:
<!-- Before: underscore instead of a hyphen -->
<html lang="en_US">
<!-- After -->
<html lang="en-US">