htmlLangs
Reports <html> elements without a lang prop.
✅ This rule is included in the jsx logical
preset.
The lang
attribute on the <html>
element identifies the language of the document for screen readers and assistive technologies.
Without it, screen readers may default to the user’s system language, causing confusion for users.
This is required for WCAG 3.1.1 compliance.
Examples
Section titled “Examples”<html> <body>Content</body></html>
<html className="root"> <body>Content</body></html>
<html lang="en"> <body>Content</body></html>
<html lang="en-US"> <body>Content</body></html>
<html lang={language}> <body>Content</body></html>
When Not To Use It
Section titled “When Not To Use It”If you’re not working with HTML documents or the <html>
element is managed by a framework, you can disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
jsx-a11y/html-has-lang
- Oxlint:
jsx_a11y/html-has-lang
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.