langValidity
Reports invalid lang attribute values.
✅ This rule is included in the jsx logical preset.
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”<div lang="">Content</div><div lang="e">Content</div><div lang="123">Content</div><html lang="en-">Content</html><div lang="en">Content</div><div lang="en-US">Content</div><div lang="zh-Hans">Content</div><div lang="zh-Hans-CN">Content</div><div lang={language}>Content</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 ❤️🔥 in Boston by
Josh Goldberg and contributors.