oxc-project/oxc · error
Missing lang attribute.
Error message
Missing lang attribute.
What it means
Raised by the jsx-a11y/html-has-lang rule when a JSX <html> element has no lang attribute. Screen readers use the lang attribute to determine pronunciation and translation of content; without it the document language is unknown to assistive technology.
Source
Thrown at crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs:17
use oxc_ast::{
AstKind,
ast::{JSXAttributeItem, JSXAttributeValue, JSXExpression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::LintContext,
rule::Rule,
utils::{get_element_type, get_prop_value, has_jsx_prop_ignore_case},
};
fn missing_lang_prop(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing lang attribute.")
.with_help("Add a `lang` attribute to the `html` element whose value represents the primary language of document.")
.with_label(span)
}
fn missing_lang_value(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing value for `lang` attribute")
.with_help("Must have meaningful value for `lang` prop.")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct HtmlHasLang;
declare_oxc_lint!(
/// ### What it does
///
/// Ensures that every HTML document has a lang attribute.
///View on GitHub (pinned to e1e7af627c)
Solutions
- Add lang="en" (or the appropriate BCP-47 language code) to the <html> element.
- If rendering multiple locales, set lang dynamically from the active locale.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs:17 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/826664ef1678b0e5.
Report an issue: GitHub.