Guides › Fix guides

Missing html lang attribute: why it matters and how to fix it

Updated 2026-10-24 · Altlark guides

The lang attribute on the <html> element tells browsers and assistive technology what language the page is written in. When it's missing, a screen reader falls back to the user's default voice. A French-speaking user reading your English page may hear English words with French pronunciation, which can be close to unintelligible. Browsers also use the language for hyphenation, spell-check, translation prompts and choosing fonts for some scripts.

It's one of the easiest accessibility fixes there is: usually one attribute in one template.

Which WCAG criteria apply

  • 3.1.1 Language of Page, Level A: "The default human language of each web page can be programmatically determined."
  • 3.1.2 Language of Parts, Level AA covers passages in a different language within the page (for example a French quote on an English page). Altlark doesn't check this one.

Bad vs fixed

Before (flagged)
<!doctype html>
<html>
<head><title>Acme Bakery</title></head>
After (fixed)
<!doctype html>
<html lang="en">
<head><title>Acme Bakery</title></head>

Use a valid language tag: en, fr, de, es, and so on. You can add a region when it matters: en-US, en-GB, pt-BR, fr-CA.

Common mistakes

Before (flagged)
<html lang="">
<html lang="english">
<html xml:lang="en">
  • An empty lang="" is the same as no language. Altlark flags it.
  • "english" isn't a valid tag; use en. Altlark currently checks that lang is present and non-empty, not that the code is valid, so double-check the value yourself.
  • xml:lang on its own isn't enough for HTML pages served as HTML; include lang.

Marking parts in another language

After (fixed)
<p>Our house specialty is the <span lang="fr">pain au chocolat</span>.</p>
<blockquote lang="es">Lo mejor de la ciudad.</blockquote>

How to fix it on common platforms

  • Static HTML or a custom site: add lang="en" to the <html> tag in your base layout template.
  • WordPress: themes should output <html <?php language_attributes(); ?>> in header.php, which uses the Site Language under Settings > General. If your scan shows no lang, the theme (or a page builder's custom header) is skipping that function. Check the theme's header.php or ask the theme developer.
  • Shopify: themes usually set the html lang from the Liquid object request.locale.iso_code in layout/theme.liquid. If yours doesn't, edit theme.liquid (back it up first).
  • Squarespace, Wix and other hosted builders: the language is normally set in the site's language or region settings. If it's set and the scan still flags it, contact the platform's support.
  • Single-page apps: set the attribute in the static index.html, not only with JavaScript after load, so it's present for every tool that reads the page.

Multilingual sites

Each language version should set its own lang: lang="en" on English pages, lang="es" on Spanish pages. Translation plugins usually handle this; scan one page in each language to make sure.

What Altlark checks exactly

Altlark looks for the <html> element in the HTML your server sends. If it's missing, or has no lang attribute, or the attribute is empty or only whitespace, it reports "Page language not set" (an error, WCAG 3.1.1). One issue per page.

Limits

A static check can't tell whether the language you declared matches the language you wrote in. A Spanish page with lang="en" passes the check but still sounds wrong to screen-reader users. If you serve different languages, spot-check each one.

Why it's worth fixing first

Of the issues Altlark finds, this one usually has the best effort-to-impact ratio: it's one line, it's sitewide, and it affects every screen-reader user on every page. In our October 2026 static scan of 333 small-business home pages, 16 (5%) had no html lang. It's uncommon, but when it's missing, it's missing everywhere.

Testing it yourself

View the page source (Ctrl+U or Cmd+Option+U in most browsers) and look at the very first <html> tag. You should see a lang attribute with a short code. Don't rely on the Elements panel in dev tools alone: it shows the page after scripts have run, and a script might add lang later even though the server HTML doesn't include it. If you have a screen reader, load a page and listen to the first few sentences; with lang set correctly, the voice should match the language of the text. On a multilingual site, switch to another language version and check that both the attribute and the voice change with it.

Checklist

  1. Run the free scan on any page; if "Page language not set" appears, it's almost certainly in your base template.
  2. Add lang with the correct code to the <html> element.
  3. Mark passages in other languages with lang on the containing element.
  4. Re-scan a few different page types (home, blog post, product) to confirm the template fix applies everywhere.

Check your page for free

Altlark scans one public page in seconds and lists each issue with the element, the WCAG criterion and the fix. No signup.

Automated checks find some, not all, accessibility issues (they catch only a portion of WCAG problems). This is not legal advice, not a legal assessment and not a certification.

Related guides

All accessibility guides · Monitoring plans

More free tools from Swift Labs