# Missing Lang Attribute: Error Explained and Fixed

Source: https://allyway.ai/glossary/missing-lang-attribute

A missing lang attribute means the html element of a page has no lang attribute, or an empty or invalid one. Browsers and screen readers then cannot tell which language the page is written in.

A missing lang attribute is the scanner error for a page whose `<html>` element does not declare the page language. Tools report it as "HTML element has no lang attribute" or "Page language not set". The fix is one attribute – but without it, a screen reader may read your whole page with the wrong pronunciation rules.

## What it means

[WCAG 3.1.1 Language of Page](https://www.w3.org/WAI/WCAG22/Understanding/language-of-page.html) is a Level A criterion of [WCAG 2.2](https://allyway.ai/regulations/wcag-2-2). It requires that the default human language of each web page can be programmatically determined. In HTML, that is the job of the `lang` attribute on the `html` element (W3C technique H57).

Why it matters: screen readers and text-to-speech load pronunciation rules for the declared language. If the page language is not set, the software falls back to the user's default voice. A German page read by an English voice is hard to follow – and the reverse is just as bad. Browsers also use the language to render characters correctly and for automatic translation, and media players use it to display captions.

W3C names these groups as the main beneficiaries:

| Who | What the lang attribute does for them |
|---|---|
| Screen reader and text-to-speech users | Correct pronunciation and voice |
| People who find reading written text hard | Text-to-speech reads words correctly |
| People with cognitive, language or learning disabilities | Reliable read-aloud support |
| People who rely on captions | Captions displayed correctly |

> **Note:** > **Which language is the "default"?**
> W3C defines it as the language used most on the page. If several languages are used equally, the first one used is the default. Passages in another language are covered by a separate Level AA rule, 3.1.2 Language of Parts.

Scanners also flag the attribute when it is present but empty (`lang=""`) or not a valid language tag. The value has to follow BCP 47 – the familiar short codes such as `en`, `de` or `en-GB`.

## Examples

```html title="Example"
<!-- Missing lang attribute: language unknown -->
<!DOCTYPE html>
<html>
  <head><title>Opening hours</title></head>

<!-- Fixed: English page -->
<html lang="en">

<!-- Fixed: British English with a region subtag -->
<html lang="en-GB">

<!-- A French quote inside the English page (3.1.2) -->
<p>Our motto: <span lang="fr">savoir-faire</span></p>
```

**Do:** Do

Set `lang` on the `html` element of every page, use the language most of the content is written in, and give each language version of a multilingual site its own code.

**Don't:** Don't

Leave `lang` empty, invent codes such as `lang="english"`, or copy the same `lang="en"` into a translated template where the content is now in German.

## How to fix a missing lang attribute



The lang attribute is a quick win for any audit against the [European Accessibility Act](https://allyway.ai/regulations/eaa), because the same missing setting usually affects every page of a site. While you are in the template, check other site-wide issues such as an [empty button](https://allyway.ai/glossary/empty-button) in the header or a [skipped heading level](https://allyway.ai/glossary/skipped-heading-level) in the footer.

## Questions

Q: What does "HTML element has no lang attribute" mean?
A: The `<html>` tag of the page does not state which language the content is in. Assistive technology then guesses or uses its default language, which often leads to wrong pronunciation.

Q: Is a missing lang attribute a WCAG failure?
A: Yes. It fails 3.1.1 Language of Page, a Level A criterion, because the page language cannot be programmatically determined. Level A is the minimum level of WCAG conformance.

Q: Should I use "en" or "en-US"?
A: Both are valid. The primary code (`en`) meets WCAG. A region subtag such as `en-US` or `en-GB` adds detail some voices and spellcheckers can use, but it is optional.

Q: Does every page need its own lang attribute?
A: Yes. The criterion applies to each web page, so every page has to declare its default language. In practice you set it once in the shared template, and each language version of the template outputs its own code.

Q: How do I check every page for a missing lang attribute?
A: Templates usually cause the error site-wide, so testing one page per template and language is a good start. The [free WCAG scanner](https://allyway.ai/free-wcag-accessibility-scanner-for-websites) shows it on the first scan, together with other Level A issues.
