Skip to main content
Accessibility

Lang attribute

Published:
Updated:

The lang attribute is a global HTML attribute that declares the language of content. On the <html> element it describes the language of the whole document (html lang); on any other element it describes the language of a passage. The value is a BCP 47 language tag: pl, en, en-GB, pt-BR.

It is primarily an accessibility requirement rather than an SEO signal. A screen reader picks its pronunciation profile from it: Polish text read with an English voice is effectively unintelligible. Hyphenation, spellchecking and the browser’s translation prompt read the same attribute.

WCAG 3.1.2 exempts proper names, technical terms, words of indeterminate language and expressions adopted into the surrounding language.

A WCAG requirement

Success criterion 3.1.1 "Language of Page" (Level A) requires the default human language of each page to be programmatically determinable. Criterion 3.1.2 "Language of Parts" (Level AA) requires passages in a language other than the page language to be marked up. WCAG 3.1.2 exempts proper names, technical terms, words of indeterminate language and expressions adopted into the surrounding language.

A missing lang attribute on <html> is a Level A failure — the lowest conformance threshold. It is also among the cheapest fixes available: one attribute in the layout template.

Declaring document and passage language
HTML
<html lang="en">
  <body>
    <p>The guest wrote: <span lang="pl">Proszę wysłać raport jutro.</span></p>
  </body>
</html>

Lang versus hreflang

The lang attribute describes one document: "this page is in English." Hreflang describes relationships between separate URLs: "the Polish version of this content is here, the English one there." The two operate at different levels and do not substitute for one another.

Each version needs a correct language declaration for accessibility. Hreflang can help search engines relate versions, but is not a WCAG requirement and cannot replace lang.

Meta content-language is obsolete

The <meta http-equiv="content-language"> tag has been removed from the HTML standard and should not be used. Google does not use it to determine language. If it is still in your template you can safely delete it — the lang attribute on <html> is the only declaration that applies.

Do not use
HTML
<meta http-equiv="content-language" content="en">

Does lang affect SEO

Google determines page language from the visible content rather than from a code declaration — the lang attribute is not used for that purpose. That does not make it irrelevant to outcomes: accessibility is part of page quality, and wrong screen reader pronunciation genuinely excludes part of your audience.

The practical conclusion: treat lang as an accessibility requirement you meet without exception, not as a ranking lever.

Common mistakes

  • No lang attribute on the <html> element — a WCAG 3.1.1 Level A failure.
  • The same lang on every language version, because a shared template never reads the locale from the URL.
  • A region alone instead of a language: lang="gb" rather than lang="en-GB".
  • An unmarked foreign-language quotation, where no WCAG 3.1.2 exception applies.
  • A leftover <meta http-equiv="content-language"> sitting beside a correct lang attribute.

Check after a language change

Open each language version and inspect html lang and screen-reader pronunciation of the quotation. Also test client-side navigation without a full reload: the template must update the document language.

Sources & further reading

Check your site’s accessibility

Insight analyses public accessibility signals, including the document language declaration, and orders findings by priority.