← Back to the blog On-page SEO checks

The HTML lang attribute: what it does and what Google ignores

The HTML lang attribute: what it does and what Google ignores

The HTML lang attribute declares the language of a page, as in <html lang="en-GB">. Screen readers, browsers and translation tools rely on it. Google mostly doesn't: it works out a page's language from the visible text and uses hreflang to connect language versions. A wrong value rarely costs rankings directly, but it is still a defect, and on multilingual sites it often points to a template problem.

What the attribute is for

Set on the root element, lang applies to the whole document. Any element inside can override it, so a French quotation in an English article can carry <blockquote lang="fr">.

The main consumers are assistive technologies. A screen reader uses the value to pick a voice and pronunciation rules, so an Italian page marked as en gets read aloud with English phonetics, which is close to unintelligible. That is why WCAG 2 lists it at Level A (Success Criterion 3.1.1, Language of Page), with 3.1.2 covering passages in another language at Level AA. Lighthouse's accessibility audit flags both a missing attribute and an invalid value.

What Google does with it

Very little. Google's documentation on multilingual sites says it determines a page's language from its visible content and doesn't rely on code-level signals such as lang attributes. Language and regional versions are tied together with hreflang annotations, in the HTML, in HTTP headers or in the sitemap. Our hreflang checker guide shows how to verify those.

So treat lang as an accessibility and quality issue, not a ranking lever. It is still a useful consistency check: when the content, the hreflang value and lang disagree, one of them is wrong.

Valid values: BCP 47 in practice

The value must be a BCP 47 language tag. Most of the time that means an ISO 639-1 language code, optionally followed by an ISO 3166-1 region code. A few correct examples:

Tags are case-insensitive, though the convention is a lowercase language and an uppercase region. A region is optional. Plain lang="en" is perfectly valid and often the better choice when the content isn't written for one country.

Two invalid values turn up again and again. en_GB, with an underscore, is a locale string from server-side code, not a BCP 47 tag. en-UK looks right but isn't: the region code for the United Kingdom is GB, and uk is the language code for Ukrainian.

Common mistakes on client sites

The most common is one value for every language. Translation plugins and headless front ends often render the same layout for all locales, so /it/ and /de/ pages ship with lang="en". Content and hreflang say Italian, the root element says English, and screen reader users get the wrong voice.

Then there is the missing attribute. Hand-built templates, landing page builders and some static exports leave it out entirely.

Updates cause the rest. On WordPress the attribute is printed by language_attributes() in the theme header and follows Settings > General > Site Language, so a new theme that hardcodes <html lang="en-US"> overrides it. Shopify themes normally output {{ request.locale.iso_code }}, and a custom theme that hardcodes the value breaks every translated market. Redesigns and replatforming are where this happens most, which is why it belongs in the website migration SEO checklist.

How to check it

View the source and look at the opening <html> tag, or type document.documentElement.lang in the browser console. Without a browser:

curl -s https://example.com/it/ | grep -o '<html[^>]*>'

curl shows the HTML the server sends. If a JavaScript framework sets the attribute in the browser, check the rendered page too. Test one URL per language and one per template type (home, category, article, product), because the value often comes from different templates.

Watching lang and hreflang with Deltio

Deltio's SEO scanner reads the lang attribute on every monitored URL, along with title, meta description, H1, canonical and hreflang. It flags a missing or invalid value and compares each scan with the previous one, so a deploy that turns lang="it" into lang="en" produces an email or Slack alert. What it can't do is judge whether the declared language matches the text on the page. That still needs a human look.

Starter costs £24 a month, or £20 billed annually, and you can try Deltio free for 14 days.

Frequently asked questions

Does the HTML lang attribute affect Google rankings?
Not directly. Google determines a page's language from its visible content and says it doesn't rely on the lang attribute. It still matters for accessibility, browser behaviour and other tools that read the page.
Should the lang value match the hreflang value?
They should describe the same language. A page annotated with hreflang="it" should have lang="it" or a regional variant such as it-IT. They don't have to be identical strings, but a page with hreflang for Italian and lang="en" signals a template error.
Is lang="en-UK" valid?
No. BCP 47 uses ISO 3166-1 region codes, and the code for the United Kingdom is GB, so the correct tag is en-GB. UK is not a valid region subtag, and lowercase uk is the language code for Ukrainian.
What about the content-language meta tag?
The HTML specification marks the http-equiv content-language pragma as non-conforming and recommends the lang attribute instead. Google ignores both for language detection, so there is no reason to add the meta tag on new pages.
Does Deltio alert me when the lang attribute changes?
Yes. Deltio's SEO scanner reads the lang attribute on every monitored URL, flags missing or invalid values and compares consecutive scans. A change is sent as an email or Slack alert.