langValidity
Reports invalid lang attribute values.
✅ This rule is included in the jsxlogicalandlogicalStrictpresets.
The lang attribute must contain a valid BCP 47 language tag to properly identify the language of content for screen readers and assistive technologies.
Invalid language tags can cause confusion for users who rely on assistive technologies.
Valid BCP 47 language tags consist of a primary language subtag (2-3 letters) optionally followed by script, region, and variant subtags.
This is required for WCAG 3.1.2 compliance.
Examples
Section titled “Examples”<any
div lang: string
lang="">Content</any
div><any
div lang: string
lang="e">Content</any
div><any
div lang: string
lang="123">Content</any
div><any
html lang: string
lang="en-">Content</any
html><any
div lang: string
lang="en">Content</any
div><any
div lang: string
lang="en-US">Content</any
div><any
div lang: string
lang="zh-Hans">Content</any
div><any
div lang: string
lang="zh-Hans-CN">Content</any
div><any
div lang: any
lang={const language: any
language}>Content</any
div>;When Not To Use It
Section titled “When Not To Use It”If you’re using a framework that manages language attributes automatically, you may want to disable this rule.
Further Reading
Section titled “Further Reading”- MDN: HTMLElement: lang property
- WCAG 3.1.2: Language of Parts
- BCP 47: Tags for Identifying Languages
Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
jsx-a11y/lang - Oxlint:
jsx_a11y/lang
Made with ❤️🔥 around the world by
the Flint team and contributors.