Skip to content
← Back to rules

jsx-a11y/lang Correctness

What it does ​

The lang prop on the <html> element must be a valid IETF BCP 47 language tag.

Why is this bad? ​

If the language of a webpage is not specified as valid, 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.

Examples ​

Examples of incorrect code for this rule:

jsx
<html>
<html lang="foo">

Examples of correct code for this rule:

jsx
<html lang="en">
<html lang="en-US">

Resources ​

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jsx-a11y"],
  "rules": {
    "jsx-a11y/lang": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsx-a11y"],
  rules: {
    "jsx-a11y/lang": "error",
  },
});
bash
oxlint --deny jsx-a11y/lang --jsx-a11y-plugin

Version ​

This rule was added in v0.1.1.

References ​