Page language setting

How the scan reads the lang attribute on the html tag, when a missing, invalid or wrong-script value is a warning, and how to set it.

What AuditX checks

The scan reads the lang attribute on the html element of the page. It runs three steps in this order. First it checks the writing system. It takes the visible text of the body (scripts, styles, noscript, template and svg removed, first 20000 characters). If the text has at least 200 letters, and 60 percent or more of them are in one writing system that does not belong to the declared language, and less than 20 percent belong to it, the result is a warning that names the writing system. This runs for Arabic, Hebrew, Cyrillic, Greek, Thai, Korean, Chinese, Japanese and the Latin-script languages in a built-in list. It also warns when the tag is not Vietnamese but at least 8 percent of the Latin letters are letters only Vietnamese uses. Second, if that did not trigger, the scan uses the accessibility audits from the Lighthouse browser run. If they could not be measured, the result is an info note marked as not measured, which limits the SEO score for that scan to 79 and can remove it when many checks are unmeasured. Third, a missing lang attribute is a warning, a value that is not a valid language tag is a warning, and a valid value passes. The check never fails. It does not compare languages inside one writing system, so Dutch text under lang="en" passes, and it does not read xml:lang, the Content-Language header or lang on other elements.

Why it matters

WCAG success criterion 3.1.1 asks that the language of a page can be determined by software. W3C explains that screen readers can then load the correct pronunciation rules and browsers can display characters and scripts correctly.

MDN recommends always specifying an appropriate value for the lang attribute, especially because of accessibility, and notes that the language is in an unknown state when nothing indicates it.

How to fix it

  1. Add a lang attribute to the html tag with a valid language tag: a two-letter language code, optionally followed by a hyphen and a region, such as en, nl or pt-BR.
  2. Use a hyphen, not an underscore, and a real code. A full language name such as English or a made-up code is not valid.
  3. If the report says the text is written in another writing system, set lang to the language the page is really written in. For right-to-left languages such as Arabic or Hebrew, also add dir="rtl".
  4. On a site with several languages, give each language version its own lang value.
<html lang="nl-NL">

Does your site pass this check? A free scan runs it with every other check and shows the result in about a minute.

Scan my site

Sources

Related checks

Last reviewed 2026-11-13.