Rampsight

All rules

Page language

The page needs a language

Why it matters

Without lang on <html> a screen reader reads the page in whatever voice it happens to have loaded — German text in an English voice is close to unintelligible.

How to fix it

  1. Add lang to the <html> element with the page’s language code (lang="de").
  2. Set it per page in a multilingual site, from the same source as the content.

In markup

Fails
<html>
Passes
<html lang="de">

The requirement behind it

This rule is one way of failing the following WCAG 2.2 success criteria. The W3C, which writes the standard, explains each of them:

Further reading

Deque University on html-has-lang (opens in new tab)

Deque maintains axe-core, the open-source engine our scanner runs. Their page documents the rule as the engine implements it.

Automated checks find failures a browser can prove. They cannot judge whether a caption is accurate, whether an alt text is useful, or whether a page can be operated end to end with a keyboard — those need a person.