Page language missing (html-has-lang)

The html-has-lang rule flags a page whose <html> element has no lang attribute, or an empty one. Without it, screen readers, translation tools and browsers have to guess which language the page is in. The fix is one attribute in the page template: <html lang="en">.

What the rule means

WCAG 3.1.1 Language of Page requires that the default human language of each page can be determined by software. In HTML that is the lang attribute on the root element. Its value is a language tag such as en, en-GB or de.

The rule is deliberately simple: it passes when <html> carries a non-empty lang. It also passes with a non-empty xml:lang, but only for XHTML documents served as XML. On an ordinary HTML page, xml:lang without lang fails, because browsers ignore it there.

What the rule does not check:

  • whether the value is a valid language tag – that is undefined;
  • whether the tag names the language the page is actually written in – a German page marked lang="en" passes;
  • passages in another language inside the page – that is WCAG 3.1.2 and the rule undefined.

Who is affected

Mainly blind and partially sighted people using a screen reader. The screen reader picks its voice and pronunciation rules from the page language. Without a lang, it falls back to the user's default, so an English page read with a German voice becomes hard to follow, and the other way round. Browser translation, hyphenation with hyphens: auto and spell checking in form fields also rely on the page language.

A missing page language is common: the WebAIM Million 2026 found it on 13.5% of the top one million home pages [3].

Why the check fails

  • Hand-written or old templates that start with a bare <html>.
  • Static site generators and starter kits whose base layout never set a language.
  • CMS themes that print the attribute from a setting that is empty on this installation.
  • Single-page apps where the server sends an empty shell and lang is only set, if at all, by JavaScript later.
  • xml:lang without lang, copied from old XHTML templates.
  • Error pages, landing pages and email-to-web views built outside the main template.

How to fix it

  1. Find the one template or layout that outputs <html> – every page inherits from it.
  2. Add lang with the page's main language. Use the short code (en, de); add a region (en-GB, de-AT) only when it matters, for example for spelling.
  3. On a multilingual site, set the value per page from the locale, never as a fixed string in a shared template.
<!-- Before: no page language -->
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Delivery and returns – Example Shop</title>
  </head>
  <body>
    <main><h1>Delivery and returns</h1></main>
  </body>
</html>
<!-- After: the page language is set on the root element -->
<!doctype html>
<html lang="en-GB">
  <head>
    <meta charset="utf-8">
    <title>Delivery and returns – Example Shop</title>
  </head>
  <body>
    <main><h1>Delivery and returns</h1></main>
  </body>
</html>

In a single-page app, render the attribute on the server or in the static index.html. Setting document.documentElement.lang after load helps, but a crawler or assistive technology that reads the first response still sees the page without a language.

How to test it manually

  1. Open the page source (Ctrl+U or Cmd+Option+U) and look at the <html> tag – or run document.documentElement.lang in the browser console. An empty result means no language.
  2. Check that the value matches the language the text is written in. The rule cannot see a wrong language.
  3. Test pages from every template: home page, article, shop, search results, 404 page.
  4. With a screen reader (NVDA is free on Windows, VoiceOver is built into macOS and iOS), read the first paragraph and listen: does the pronunciation fit the language?

3.1.1 Language of Page, Level A. Related: 3.1.2 Language of Parts for passages in another language inside the page.

How Reviseberg reports it

Reviseberg runs html-has-lang on every crawled page at 1280px. Because the attribute comes from a shared template, the finding usually appears on every page at once – one element per page. The issue list shows the rule with its severity, WCAG criterion 3.1.1 and level, the number of pages, and the points you get back by fixing it. The detail view shows the selector (html), the HTML snippet of the opening tag and every affected page, so you can tell a site-wide template problem from a single stray page. You can mark a finding as "ignore", "can't fix" or "false positive" with a reason; every decision is logged.

  • undefined – the page has a lang, but its value is not a valid language tag.
  • undefined – an invalid lang on a passage inside the page.
  • undefined – the other template-level fact every page needs.

Check the page language across your whole site – get a free scan

Frequently asked questions

Is lang="en" enough, or do I need en-GB?

en is enough for WCAG 3.1.1. A region subtag such as en-GB or en-US helps spell checking and some voices, but it is optional.

My site is in English only. Do I still need the attribute?

Yes. A screen reader does not assume English; it uses its own default language, which may be German, Spanish or anything else.

Does setting lang with JavaScript count?

Browsers and assistive technology read the attribute from the DOM, so it works once set. It is still safer in the HTML the server sends, because tools that read the first response never see a value added later.

Does the rule check that the language is correct?

No. It only checks that a value exists. Whether it is valid is html-lang-valid; whether it is the right language needs a person.

Sources

  1. W3C, Understanding SC 3.1.1 Language of Page – https://www.w3.org/WAI/WCAG22/Understanding/language-of-page
  2. Deque University, axe-core 4.13 rule html-has-lang – https://dequeuniversity.com/rules/axe/4.13/html-has-lang
  3. WebAIM, The WebAIM Million (2026) – https://webaim.org/projects/million/
  4. W3C, Technique H57: Using the language attribute on the HTML element – https://www.w3.org/WAI/WCAG22/Techniques/html/H57
  5. W3C Internationalization, Language tags in HTML and XML – https://www.w3.org/International/articles/language-tags/

See what a scan finds on your site

One page in about thirty seconds, no email needed. The full report covers up to 100 pages and a keyboard journey.