A missing or wrong lang attribute is one of the most common and most invisible accessibility defects. The page looks fine, but a screen reader announces French content in an English voice, garbling pronunciation. This checker validates the root document language and every inline language part against the BCP 47 grammar so you can fix both WCAG language criteria at once.
How it works
The tool parses your HTML in the browser, then runs two checks.
Root language (WCAG 3.1.1). It reads the lang attribute on the html element. If absent, that is an immediate failure. If present, the value is validated against BCP 47.
Inline parts (WCAG 3.1.2). It finds every other element carrying a lang attribute and validates each one, reporting a short text preview so you can see which phrase it applies to.
BCP 47 validation
Each tag is split on hyphens and matched against the RFC 5646 subtag grammar:
- primary language — 2 to 8 letters (ISO 639). Two-letter codes are additionally checked against the ISO 639-1 list to catch typos.
- script — exactly 4 letters (ISO 15924), for example
Hant. - region — 2 letters (ISO 3166-1) or 3 digits (UN M.49), for example
GBor419. - variant — 5 to 8 alphanumerics, or 4 characters beginning with a digit.
- extension / private use — a single-character singleton followed by more subtags.
A tag passes only when the whole string fits this grammar with no leftover subtags.
Examples
en-GB valid: English, United Kingdom
zh-Hant valid: Chinese, Traditional script
fr valid: French
english invalid: primary subtag must be a 2 to 8 letter code, not a word
en_US invalid: BCP 47 uses hyphens, not underscores
Tips
- Set
langonhtmlonce for the whole page; do not repeat it on every element. - Only add inline
langwhen the language genuinely changes. A single borrowed word that has entered the main language usually does not need it. - Prefer the shortest valid tag. Use
enunless a regional distinction matters, thenen-GBoren-US. - All validation is local. Nothing you paste leaves your browser.