Language attribute missing

The lang attribute on <html> tells screen readers which pronunciation to use and search engines which language to file the page under.

Do this: Set lang on the html element from your locale variable. Screen readers pick their pronunciation from it; without it the output can be unintelligible.
PassEvery page declares its language.
LowPages have no lang attribute.

The fix, in one snippet

Example to adapt Region subtag only where it matters
<html lang="en">
<html lang="en-GB">

Illustrative values. Change the paths, hostnames and options to match your own site before using it.

The sections below explain what is tested, why it matters and the alternatives.

What we test

We read the lang attribute from the <html> element of each page and report those where it is absent or empty. The value itself is not validated beyond being present, because a wrong-but-plausible code cannot be distinguished from a correct one without reading the content.

An xml:lang attribute alone does not satisfy the check; in HTML documents browsers and assistive technology read the plain lang attribute.

Why it matters

A screen reader chooses its voice and pronunciation rules from this attribute. With no value, English text may be read with a French synthesiser or vice versa, which is not a minor inconvenience: the output becomes incomprehensible. WCAG 3.1.1 requires it for that reason.

Search engines determine language mainly from the content itself, but the attribute is a corroborating signal, and it matters more on pages with little text, on mixed-language sites, and wherever hreflang annotations are in use, since those are matched against the declared language.

Browsers also use it for hyphenation, quotation marks and font selection, so the rendered text improves as well.

How to fix it

Set it on the root element, with a region subtag only where the regional variant genuinely differs:

<html lang="en">        <!-- English -->
<html lang="en-GB">     <!-- British English, where spelling matters -->
<html lang="de">        <!-- German -->

Mark passages in another language inline with <span lang="fr"> so the reader switches voice for that phrase and back afterwards. On a multilingual site, generate the attribute from the same locale variable that selects the translations, so the two cannot disagree.

Where this fits

Language attribute missing is check 6 of 7 that the seo & site health audit runs under technical seo and speed, ordered the way they are worth fixing. That ordering is the point: Fixing this one while the check above it still fails buys less than it looks like.

Fix this one first

Above it in the same category sits http:// references on HTTPS pages (medium), where links from an HTTPS page to http:// URLs cost a redirect on every click and expose the first request. An attacker who has that does not need this, so it is the better use of the same hour.

What fixing this still leaves open

Language attribute missing closes one route in. The next one down is No cache policy on HTML, where hTML with no cache policy is re-downloaded in full on every visit, including every back-button navigation.

Found in the same scan

The seo & site health audit reports this alongside checks from other categories that are at least as serious, including Broken internal links, where an internal link that returns an error is a dead end for the reader and a wasted request for the crawler, and Crawl errors (4xx / 5xx), where uRLs reached during the crawl that returned a client or server error. A single run of seo & site health audit answers all of them at once.

Prompt for an AI Hand this check to an assistant Sign in to copy it
The first few lines
You are a senior web engineer. I ran a security and SEO scanner against my site and it reported the finding below. Fix it properly rather than suppressing the symptom.

Finding: Language attribute missing (low severity)
Scanner check id: seo-lang-attribute
18 more lines, including the evidence and the exact fix

The rest of this prompt names the pages and line numbers we found the problem on, the configuration to change, and the constraints a good answer has to respect. It is free, it just needs an account so the work is not scraped wholesale.

Sign in with Google

Signing in is free and takes one click. We store your email address and nothing else.

References

  1. WCAG 3.1.1: language of page
  2. MDN: the lang attribute