oxc-project/oxc · error
Missing value for `lang` attribute
Error message
Missing value for `lang` attribute
What it means
Raised by jsx-a11y/html-has-lang when the <html> element has a lang attribute whose value is missing or empty (e.g. lang="" or a lang attribute with no value). An empty language tag conveys no language information to assistive technology.
Source
Thrown at crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs:23
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.
///
/// ### Why is this bad?
///
/// If the language of a webpage is not specified,
/// the screen reader assumes the default language set by the user.
/// Language settings become an issue for users who speak multiple languages
/// and access website in more than one language.View on GitHub (pinned to e1e7af627c)
Solutions
- Set lang to a valid non-empty BCP-47 language tag such as lang="en" or lang="pt-BR".
- If the value comes from a variable, ensure it is a defined string at render time.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/jsx_a11y/html_has_lang.rs:23 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/c87948e5b12e06c6.
Report an issue: GitHub.