The HTML lang Attribute
What the HTML lang attribute does, why Google ignores it for language detection but Bing uses it, how it differs from hreflang, and why it still matters for accessibility and the browser auto-translate prompt.
1 evidence signal on this page
- Related live toolOn-Page SEO Checker
The HTML lang attribute — set on the root as <html lang="en"> (or a region variant like en-US) — declares the natural language of THIS document's content using a BCP 47 tag. It is not the same as hreflang: lang describes the page it's on; hreflang declares alternate-language URLs for other pages. Google is blunt that it ignores lang for language detection ('we don't use that at all… almost always wrong' — Mueller); it uses content algorithms instead. Bing is the opposite: its 2011 Webmaster Blog names <html lang> as a fallback document-location signal, behind the content-language meta tag. Regardless of search weight, lang is a required accessibility attribute (WCAG 3.1.1) — it drives screen-reader pronunciation and the browser's auto-translate prompt, and 'missing document language' is still a top-six WebAIM Million failure. The one Google carve-out: labeling machine-translated blocks with lang="es-x-mtfrom-en". Set a valid value, keep it consistent with hreflang, and don't leave a boilerplate lang="en" on non-English content.
TL;DR — The HTML
langattribute — thelang="en"on your page’s opening<html>tag — tells browsers and screen readers what language your page’s content is written in. It’s easy to mix up with hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others., but they’re different:langdescribes this page; hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. points to your other language versions. Google doesn’t uselangto detect a page’s language, while the attribute still matters for accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. and for whether your browser offers to translate a page.
What the lang attribute is
Near the very top of most web pages is a tag that looks like this:
<html lang="en">That lang="en" is the HTML lang attributeThe HTML lang attribute is a global attribute — most importantly set on the <html> element (<html lang=\"en\">) — that declares the natural language of THIS document's content using a BCP 47 language tag (en, es, en-US, pt-BR). It's distinct from hreflang, which points to alternate-language URLs. Google ignores lang for language detection; Bing uses it as a fallback targeting signal; and it drives accessibility (screen-reader pronunciation) and the browser auto-translate prompt.. Its one job is to declare the
language the page’s content is written in — en for English, es for Spanish,
de for German. You can get more specific with a region: en-US for American
English, en-GB for British English, pt-BR for Brazilian Portuguese.
It’s a small thing, but a few different systems read it:
- Screen readers use it to pronounce your words correctly — an English voice reading French text sounds like nonsense. Evidence for this claim WCAG 2.2 success criterion 3.1.1 requires the default human language of a page to be programmatically determinable, and W3C lists lang on the html element as a sufficient HTML technique. Scope: WCAG 2.2 Level A language-of-page requirement for HTML documents. Confidence: high · Verified: W3C: Understanding Language of Page
- Browsers use it (along with the actual text) to decide whether to pop up “Translate this page?”
- Google mostly ignores it (more on why in the Advanced tab).
lang is not hreflang
This is the confusion that sends most people to a page like this one. Here’s the one-line difference:
lang= “the content on this page is in this language.” One value, set on your<html>tag.- hreflang = “here are the other URLs that are the German, Spanish, and French versions of this page.” A set of links pointing to other pages.
lang is a self-description. Hreflang is a map to your alternate pages. A simple
single-language site needs a correct lang and no hreflang at all. If you run a
multilingual site, you’ll have both — and they should agree with each other.
What value should you use?
Use a real language code, not something you made up:
- Just the language if you don’t care about regional variants:
en,es,fr. - Language plus region if you do:
en-US,en-GB,pt-BR.
Don’t invent codes like eng or en-UK (the correct code for the UK is GB,
not UK). And don’t leave the default lang="en" sitting on a page whose content
isn’t actually in English — that’s the single most common mistake, and it causes
real problems with translation prompts and screen readers.
Want the deeper version — exactly why Google ignores it, how Bing uses it, the accessibility rules, and the browser auto-translate story? Switch to the Advanced tab.
TL;DR —
langdeclares the natural language of this document (<html lang="en">, or a region variant likeen-US) using a BCP 47 tag. It is a different mechanism from hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others., which declares alternate-language URLs — Google’s own docs group the two together as things it does not use to detect a page’s language. Mueller: “we don’t use that at all… almost always wrong.” Regardless of search weight, a programmatically determinable page language is a WCAGWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. 3.1.1 Level A requirement, and the HTMLlangattribute is the standard technique. It supports screen-reader pronunciation and the browser auto-translate prompt, and “missing document language” is still a top-six WebAIM Million failure. The one Google carve-out: labeling machine-translated blocks withlang="es-x-mtfrom-en". Set a valid value, keep it consistent with hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others., and kill the boilerplatelang="en"on non-English pages.
What the lang attribute actually declares
The HTML lang attribute is a global attribute — it can technically go on any
element — but the one that matters most sits on the root: <html lang="en">. Its
value is a BCP 47 language tag, either a language subtag on its own (en,
es, de) or a language-plus-region pair (en-US, en-GB, pt-BR, zh-Hans).
What it declares is narrow and specific: the natural language of the text content on the document it’s set on. Not the language of your alternate pages, not the country you’re targeting — just “the words on this page are in this language.”
Evidence for this claim The HTML lang attribute specifies an element's language using a valid BCP 47 language tag; on the root html element it establishes the document's default language. Scope: WHATWG HTML language semantics and IETF BCP 47 tag syntax. Confidence: high · Verified: WHATWG: The lang attribute IETF RFC 5646 Evidence for this claim WCAG 2.2 success criterion 3.1.1 requires the default human language of a page to be programmatically determinable, and W3C lists lang on the html element as a sufficient HTML technique. Scope: WCAG 2.2 Level A language-of-page requirement for HTML documents. Confidence: high · Verified: W3C: Understanding Language of PageThree precision points worth internalizing, drawn from the MDN reference:
- Valid values only. A BCP 47 tag — not a made-up three-letter code (
eng), not a full language name, and noten-UK(the region subtag for the United Kingdom isGB). Invalid values get treated as no value. Syntactically well-formed isn’t the same as correct, either:lang="en"is a perfectly valid tag that’s still wrong on a French page. Validity is a floor, not a guarantee the value actually matches the content (more on that in the boilerplate-default trap below). - Empty is not the same as absent. An explicit
lang=""means “unknown language” — a deliberate state. A genuinely missing attribute is a different failure mode, and accessibility tools flag it as absent rather than explicitly-unknown. - The root value is a default, not a lock.
<html lang>sets what every descendant inherits unless it’s overridden — resetlanglocally on any element containing a real language change (see “Set it on the element that changes, too” below). Don’t confuse this in-document declaration with the HTTPContent-Languageresponse header: that header describes transport metadata about the response, not the parsed document, and it isn’t a substitute forlangwhen it comes to element-level inheritance or accessibility.
lang vs. hreflang: the confusion, resolved
If you landed here from a hreflang question, this is the section you want. These two get conflated constantly because they’re both language-related, both live at or near the top of the document, and both use similar-looking codes. But they do unrelated jobs.
The cleanest articulation comes straight from Google’s own documentation on localized versions of your pages, which groups the two together precisely to say it uses neither for detection:
“Google doesn’t use hreflang or the HTML lang attributeThe HTML lang attribute is a global attribute — most importantly set on the <html> element (<html lang=\"en\">) — that declares the natural language of THIS document's content using a BCP 47 language tag (en, es, en-US, pt-BR). It's distinct from hreflang, which points to alternate-language URLs. Google ignores lang for language detection; Bing uses it as a fallback targeting signal; and it drives accessibility (screen-reader pronunciation) and the browser auto-translate prompt. to detect the language of a page; instead, we use algorithms to determine the language.”
Read that carefully. Google names both lang and hreflang in one breath — as two
separate things it does not use to figure out what language a page is in. It
detects language from the rendered, visible content instead.
So what’s the actual difference?
langis a self-description: one value, on<html>(or any element), saying “this document’s content is in this language.” Read by browsers, screen readers, spell-checkers; used by Bing; ignored by Google for detection.- hreflang is a cross-page map: a set of
<link rel="alternate">annotations (or the sitemapA sitemap is a file that lists the pages, images, videos, and other files on your site so search engines can discover them. It helps discovery, but submitting a sitemap doesn't guarantee crawling or indexing./header equivalent) listing the other URLs that are alternate language/region versions of this page, and which language each targets. It’s a routing signal Google does use — to serve the right URL variant in results — not a detection signal.
They can and often should coexist. A Mexican-Spanish page carries <html lang="es-MX"> describing its own content and a set of hreflang tags pointing to
its en-US, en-GB, and other siblings. The full implementation of hreflang —
the three methods, the reciprocal-linking rule, the self-referential rule, and the
scale of how often it breaks — is its own deep dive; this article deliberately
doesn’t re-derive it. The one thing to carry across: lang is the simple half
of this pair (one value, one element, no reciprocity) precisely because it doesn’t
carry hreflang’s cross-page relationship complexity — which John Mueller once
called “one of the most complex aspects of SEO.” Easy to set, though, is not the
same as commonly correct.
The root lang attribute gives one page a BCP 47 language self-description used by browsers and screen readers. Hreflang is a reciprocal cross-page map between alternate URLs, such as en-US and es-MX versions. Google detects a page's language from visible content rather than either annotation, but the lang value should remain accurate and consistent with the hreflang entry for the same URL.
© Patrick Stox LLC · CC BY 4.0 ·
Is the lang attribute a Google ranking factor?
Short answer: no, and Google has been unusually blunt about it. The definitive statement is John Mueller’s, reported by Barry Schwartz at Search Engine Roundtable in Google: We Ignore The HTML lang Attribute. Asked how important it is to declare a page’s language in the HTML, Mueller said:
“We don’t use that at all. So we use the hreflang links if you have that if you have different language versions. But the language attribute within the HTML markup is something we don’t use at all. We’ve foundA 302 (\"Found\") is a temporary redirect: it forwards users to a new URL while telling search engines the original URL should stay in the index. It's a weak canonicalization signal, not the zero-equity dead end of SEO folklore. that this language markup is something that is almost always wrong. So we tend to ignore that.”
That “almost always wrong” is the key phrase. Google’s reason for ignoring lang
isn’t “it’s unimportant” — it’s that the signal is unreliable at web scale.
People leave boilerplate lang="en" defaults in place after localizing content;
CMSA content management system (CMS) is software that lets users create, manage, and publish digital content — like blog posts and pages — without writing raw code. WordPress, Drupal, and Joomla are the most common open-source CMS platforms. and framework templates ship a default that never gets updated (Vue CLI’s
generated boilerplate, for instance, hard-codes lang="en" regardless of what
you build with it). When a signal is wrong that often, the sane engineering move
is to stop trusting it and detect language from the content directly — which is
exactly what Google says it does. That 2016 quote is old, but the current (2026)
Search Central doc quoted above independently restates the same policy, so treat
it as long-standing, unretracted guidance rather than a stale one-off.
The one exception: machine-translated content
There’s a single, narrow place where Google’s docs do care about a lang-style
value. If you publish machine-translated content, Google’s
translated-results guidance
asks you to mark those blocks with a special value format —
lang="<target>-x-mtfrom-<source>", e.g. lang="es-x-mtfrom-en" for content
machine-translated from English into Spanish. That’s the exception that proves the
rule: Google ignores lang for general language detection, but this specific
labeling convention is one it defined and reads. (The related lever, if you want
to opt out of translation features entirely, is the notranslate rule — “To opt
out of all translation features in Google Search, use the notranslate rule, which
can be implemented as a meta tag or an HTTP header,” per the same doc.)
Does Bing use the lang attribute?
Yes — and this is where lang gets genuinely more consequential than the “Google
ignores it” story suggests. Bing’s stance is the opposite of Google’s, and it’s
under-covered almost everywhere.
In its 2011 Webmaster Blog post How To Tell Bing Your Website’s Country and Language, Bing lays out a priority order of “document location” signals it uses for relevance. The order, top to bottom:
- The
content-languagemeta tag in the<head>(<meta http-equiv="content-language" content="en-us">). - The
<html lang="en-us">attribute, then the<title lang="en-us">attribute, as fallbacks — “the priority order for these tags is:<meta>,<html>,<title>.” - ccTLDCountry-code top-level domain like .de or .co.uk — a strong geotargeting signal..
- Reverse-IP lookup — used only when the higher signals are inconclusive.
Bing’s advice is to pick one and be consistent: “It’s best that you use one
option, instead of multiple options here.” So unlike Google, Bing explicitly uses
<html lang> as a real (if lower-priority) targeting signal. For a site with
meaningful Bing traffic, that changes the recommended action: set lang
correctly, and consider a matching content-language meta tag on top.
This also closes the loop with the hreflang side of things: Bing barely uses
hreflang the way Google does — content-language plus lang is Bing’s parallel
mechanism.
Why the lang attribute matters anyway: accessibility
Even setting search aside entirely, lang earns its place. It is a required
accessibility attribute — WCAG Success Criterion 3.1.1 (Level A) requires the
default human language of each page to be programmatically determinable, which in
practice means a valid <html lang>. A separate criterion, 3.1.2, covers marking
language changes within a page.
The downstream effects are concrete and well-documented (Adrian Roselli’s
On Use of Lang Attribute
catalogs many): screen readers use lang to pick the correct pronunciation engine
and voice (JAWS’s phonetic engine, VoiceOver’s automatic voice switching), CSS
hyphens: auto depends on it, spellcheck behavior keys off it, quotation-mark
renderingTurning HTML, CSS, and JavaScript into the final visual page and DOM. and default CJK font selection follow it, and Braille displays behave
differently with it. Exactly how each of these plays out varies by screen reader,
browser, and installed voice — Roselli’s own tests show JAWS and VoiceOver don’t
behave identically — so treat a correct lang value as enabling the right
behavior, not guaranteeing an identical experience across every assistive-technology
stack.
And it’s not a solved problem. Per the current
WebAIM Million report, “missing document
language” sits at 13.5% of home pages — the sixth most common automated
accessibility failure on the web. The rate is improving (down from 15.8% the
prior year, and 17.1% and 18.6% before that), but “a large, shrinking problem” is
still a problem. Google’s own tooling reflects the framing: LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s
html-has-lang and html-lang-valid checks live under its Accessibility
category, not its SEO category — a nice tell that even Google’s developer tools
bucket lang as an a11y concern, not a ranking one. Those checks are built on
Deque’s axe-core rule of the same name,
which classifies a missing lang as a WCAG 2.0/2.1 Level A “Serious” issue.
Browser behavior: the auto-translate prompt
There’s one more visible behavior lang governs: the browser’s “Translate this
page?” prompt. Chrome (and others) weigh lang alongside actual visible-text
analysis when deciding whether to offer translation. A wrong or missing value can
misfire in both directions — falsely offering to translate a page that’s already
in the reader’s language, or failing to offer it on a genuinely foreign one.
The vivid real-world example is Manuel Matuzovic’s
the lang attribute: browsers telling lies, telling sweet little lies:
the Austrian broadcaster ORF.at shipped German content with lang="en", so
Chrome’s auto-translate treated the German text as English and “translated” it,
turning the Vienna district name “Liesing” into the English word “lies.” That’s
the boilerplate-default trap producing a user-facing bug — the exact class of
problem Mueller’s “almost always wrong” was describing.
How to set it correctly
- Use a valid BCP 47 tag. Language subtag alone (
en,es,fr) if you don’t need regional distinction; language-region (en-US,en-GB,pt-BR) if you do. Pull codes from the IANA Language Subtag Registry; don’t invent them, and rememberGB, notUK. - Set it on the element that changes, too. For an embedded foreign phrase in
an otherwise single-language page, reset
langlocally:<span lang="fr">c'est la vie</span>. Unset descendants inherit the nearest ancestor’slang, so the root value covers everything you don’t override. - Kill the boilerplate default. The
lang="en"your template or CMS shipped with is only correct if your content is actually in English. This is the failure Mueller called out and the ORF.at bug in miniature — audit for it. - Keep lang and hreflang consistent. If a page’s
langsayses-MXbut its hreflang annotation for that same URL saysen, that’s a mismatch. It’s exactly the “Hreflang and HTML lang mismatch” issue I documented in Ahrefs’ hreflang guide — where I put it plainly: “Google doesn’t use the HTML language attribute, but other search engines and browsers do. It’s important to keep these two attributes consistent with one another.” Google ignores thelanghalf of that comparison, but a mismatch still signals that something is misconfigured — which is why site audit tools flag it.
Common myths
- “Correct
langwill improve my Google rankings.” No. Google states it doesn’t uselangfor language detection at all. It can matter for Bing and indirectly help via accessibility and translation behavior, but a direct Google ranking benefit isn’t supported. - “
langand hreflang are basically the same.” No —langdescribes the page it’s on; hreflang points to other URLs. A page can have a correctlangand no hreflang, or correct hreflang and a wronglang. - “No search engine cares about
lang.” Bing explicitly does (as a fallback behindcontent-language). For any site with real Bing traffic, this isn’t a “nobody cares” situation. - “Leaving the default
lang="en"is harmless if my content isn’t English.” It’s close to word-for-word the failure Mueller called “almost always wrong,” and it’s what triggers wrong translate prompts and wrong screen-reader pronunciation. - “Correct
langgives a 22% CTR lift” / “AI crawlersAI crawlers are bots from AI companies that fetch web pages to train language models, build AI-search indexes, or answer live user questions. They come in three categories, each with its own user-agent tokens and its own robots.txt controls. process lang-tagged pages 40% faster.” These specific figures circulate on a handful of SEO marketing blogs with no traceable study, methodology, or primary source. I couldn’t corroborate either against any official statement or first-party data — treat them as the kind of confident-sounding, baseless folklore that accretes around low-scrutiny technical topics. - “An empty
lang=""is the same as not having one.” No — an explicit empty value means “unknown language,” a distinct state from a genuinely absent attribute.
Where this fits
This is the attribute-level deep dive of the HTML SEOHTML SEO is the practice of writing and structuring a page's HTML so search engines can efficiently crawl, render, parse, and understand its content — the elements they read directly, how they handle imperfect markup, and where the right element for the job helps machine understanding. subcluster — the sibling
to the element-level treatment of <article>, <nav>, and <main> in the
semantic HTMLSemantic HTML is the practice of using elements like <main>, <article>, <section>, <nav>, <header>, and <aside> to describe what content is, not just how it looks. It helps search engines and assistive tech identify a page's main content more reliably, but it isn't a ranking factor on its own. article, and to the broader HTML-SEO hub above them. For the full
cross-page targeting story — the three implementation methods, reciprocal rules,
and how often clusters break at scale — the hreflang deep dive is the place to go;
this article’s job is just to keep the two straight in your head.
AI summary
A condensed take on the Advanced version:
langdeclares the language of this document (<html lang="en">, or a region variant likeen-US) using a BCP 47 tag. It’s a self-description, not a targeting or routing mechanism.- It is not hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others.. Google’s own docs group both together as things it does
not use for language detection: “Google doesn’t use hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. or the HTML
lang attribute to detect the language of a page… we use algorithms.”
langdescribes the page it’s on; hreflang points to alternate-language URLs. - Google ignores
langfor detection — Mueller: “we don’t use that at all… almost always wrong,” because boilerplate/CMSA content management system (CMS) is software that lets users create, manage, and publish digital content — like blog posts and pages — without writing raw code. WordPress, Drupal, and Joomla are the most common open-source CMS platforms. defaults make it unreliable at scale. One carve-out: labeling machine-translated blocks withlang="es-x-mtfrom-en". - Bing does the opposite: its 2011 Webmaster Blog names
<html lang>as a fallback document-location signal, behind thecontent-languagemeta tag (order: meta > html > title). For Bing traffic, setlangcorrectly. - AccessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. is the real stakes: WCAG 3.1.1 requires it; it drives
screen-reader pronunciation,
hyphens: auto, spellcheck, and CJK fonts. “Missing document language” is still ~13.5% of home pages — a top-six WebAIM Million failure, though shrinking. - Browsers use it for the auto-translate prompt — a wrong value misfires (the
ORF.at
lang="en"-on-German bug that “translated” a district name into “lies”). - Get it right: valid BCP 47 tag (
GB, notUK), resetlangon embedded foreign phrases, kill boilerplatelang="en"on non-English pages, and keeplangconsistent with hreflang (the “Hreflang and HTML lang mismatch” audit issue).
Official documentation
Primary-source documentation and standards references.
- Localized Versions of your Pages — the “Google doesn’t use hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. or the HTML lang attributeThe HTML lang attribute is a global attribute — most importantly set on the <html> element (<html lang=\"en\">) — that declares the natural language of THIS document's content using a BCP 47 language tag (en, es, en-US, pt-BR). It's distinct from hreflang, which points to alternate-language URLs. Google ignores lang for language detection; Bing uses it as a fallback targeting signal; and it drives accessibility (screen-reader pronunciation) and the browser auto-translate prompt. to detect the language of a page” line.
- Translated Google Search Results — the
lang="x-mtfrom-"machine-translation labeling convention and thenotranslateopt-out. - Managing Multi-Regional and Multilingual Sites — adjacent context on language/region signals.
Bing / Microsoft
- How To Tell Bing Your Website’s Country and Language (Bing WebmasterMicrosoft's free portal for monitoring and improving how a site appears in Bing search — the peer to Google Search Console, plus IndexNow instant indexing, richer backlink data, and keyword volumes. Because Bing's index also feeds Microsoft Copilot, it doubles as a window into AI-search visibility. Blog, 2011) — the
meta > html > titledocument-location priority order. Original URL is delisted; text confirmed via the Wayback Machine capture.
Standards / technical references
- MDN —
langglobal attribute — BCP 47 requirement, empty-string vs. absent behavior, inheritance, WCAGWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. references. - W3C Internationalization — Declaring language in HTML — BCP 47 / IANA registry guidance and nested-element rules for mixed-language content.
- Deque University — axe rule
html-has-lang— the WCAG 2.0/2.1 Level A classification behind LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s accessibility audit. - WebAIM Million — the annual accessibility survey with the “missing document language” failure rate.
Quotes from the source
On-the-record statements. Each link deep-links to the quoted passage where the source page supports it.
Google — it doesn’t use lang for detection
- “Google doesn’t use hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. or the HTML lang attributeThe HTML lang attribute is a global attribute — most importantly set on the <html> element (<html lang=\"en\">) — that declares the natural language of THIS document's content using a BCP 47 language tag (en, es, en-US, pt-BR). It's distinct from hreflang, which points to alternate-language URLs. Google ignores lang for language detection; Bing uses it as a fallback targeting signal; and it drives accessibility (screen-reader pronunciation) and the browser auto-translate prompt. to detect the language of a page; instead, we use algorithms to determine the language.” — Google Search Central docs. Jump to quote
Google — the machine-translation carve-out and notranslate
- “To opt out of all translation features in Google Search, use the notranslate rule, which can be implemented as a meta tag or an HTTP header.” — Translated Google Search Results. Jump to quote
John Mueller, Google — “almost always wrong”
- “We don’t use that at all. So we use the hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. links if you have that if you have different language versions. But the language attribute within the HTML markup is something we don’t use at all. We’ve foundA 302 (\"Found\") is a temporary redirect: it forwards users to a new URL while telling search engines the original URL should stay in the index. It's a weak canonicalization signal, not the zero-equity dead end of SEO folklore. that this language markup is something that is almost always wrong. So we tend to ignore that.” — via Search Engine Roundtable’s coverage of a 2016 Google Webmaster hangout. Read the coverage Relayed via Barry Schwartz’s write-up of the 2016 hangout (the original video isn’t independently reachable). The underlying “we don’t use lang for detection” policy is independently reconfirmed by the current Search Central doc quoted above, so I treat the position as still accurate despite the quote’s age.
Bing / Microsoft — lang is a fallback targeting signal
- Priority order for document-location signals: “the priority order for these tags is:
<meta>,<html>,<title>,” with a recommendation to “use one option, instead of multiple options here.” — Bing WebmasterMicrosoft's free portal for monitoring and improving how a site appears in Bing search — the peer to Google Search Console, plus IndexNow instant indexing, richer backlink data, and keyword volumes. Because Bing's index also feeds Microsoft Copilot, it doubles as a window into AI-search visibility. Blog, “How To Tell Bing Your Website’s Country and Language,” 2011. Quoted from the 2011 post via its Wayback Machine capture — the original URL is delisted from Bing’s current blog archive, and no newer Bing statement supersedes the mechanism that I could find. Its age (2011) is a real caveat; I’m citing it as long-standing but old.
Me — keeping lang and hreflang consistent
- “Google doesn’t use the HTML language attribute, but other search engines and browsers do. It’s important to keep these two attributes consistent with one another.” — from Ahrefs’ hreflang guide, on the “Hreflang and HTML lang mismatch” audit issue. Read it
Which language tag do I actually need?
A quick walk-through when you’re staring at a page and not sure what to set.
1. Do you just need to declare what language this page is in?
That’s the lang attribute. Set <html lang="…">. Go to step 2.
2. Do you need to distinguish regional variants (US vs. UK English, Brazilian vs. European Portuguese)?
- No → use the language subtag alone:
<html lang="en">,lang="es",lang="pt">. - Yes → use language-region:
<html lang="en-US">,lang="en-GB">,lang="pt-BR">. (Region isGB, notUK.)
3. Does the page contain passages in a different language (a French quote in an English article)?
- Yes → wrap them and reset locally:
<span lang="fr">c'est la vie</span>. Everything else inherits the root<html lang>. - No → the root value covers the whole page.
4. Do you also have the same page in other languages at other URLs?
- Yes → you additionally need hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. — a separate mechanism pointing to
those alternate URLs. Keep each page’s
langconsistent with its hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. entry. (See the hreflang deep dive; that’s its own build.) - No → you’re done with
langalone.
5. Is the content machine-translated?
- Yes → per Google, label the translated block:
lang="<target>-x-mtfrom-<source>"(e.g.lang="es-x-mtfrom-en"). - No → a plain BCP 47 tag is all you need.
6. Does Bing traffic matter to you?
- Yes → set
langcorrectly and consider a matchingcontent-languagemeta tag — Bing weights meta above<html lang>. Pick one consistent value; don’t set conflicting ones. - No →
langon<html>plus accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. correctness is enough.
lang attribute cheat sheet
lang vs. hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. — the one-line difference
lang | hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. | |
|---|---|---|
| Declares | The language of this page’s content | The other URLs that are alternate-language versions |
| Shape | One value on <html> (or any element) | A set of <link rel="alternate"> annotations (or sitemapA sitemap is a file that lists the pages, images, videos, and other files on your site so search engines can discover them. It helps discovery, but submitting a sitemap doesn't guarantee crawling or indexing./header) |
| Google uses it? | No (ignored for detection) | Yes — to route the right URL variant |
| Bing uses it? | Yes — fallback targeting signal | Barely |
| AccessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. / translate prompt? | Yes | No |
Who reads <html lang>
| Consumer | What it does with it |
|---|---|
| Ignores it for language detection (algorithms instead) | |
| Bing | Fallback targeting signal, behind content-language meta |
| Screen readers | Pronunciation / voice selection (WCAG 3.1.1) |
| Browsers | One input to the auto-translate prompt |
| CSS / spellcheck | hyphens: auto, spellcheck, quotation marks, CJK fonts |
Valid values
- Language only:
en,es,fr,de - Language-region:
en-US,en-GB,pt-BR,zh-Hans - Invalid:
eng(three-letter),en-UK(useGB), full language names lang=""= “unknown” (a real state, different from absent)- Machine-translated block:
lang="es-x-mtfrom-en"
Fast facts
- Mueller:
langis “almost always wrong” — Google ignores it for detection. - Bing priority order: meta
content-language><html lang>><title lang>. - “Missing document language” ≈ 13.5% of home pages (WebAIM Million, top-six failure, trending down).
- LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s
html-has-langlives under Accessibility, not SEO. - Keep
langconsistent with hreflang — the “Hreflang and HTML lang mismatch” audit issue.
HTML lang mistakes
- Leaving
lang="en"in every localized template. Set the language from the actual document locale and test non-English routes. - Using
langinstead of hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others..langdescribes this document; hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. connects alternate URLs. Implement each for its own job. - Adding a country code that does not match the content. Use a valid BCP 47 tag and add a region only when the language variant is genuinely regional.
- Putting the attribute on a wrapper instead of the root
<html>. Declare the page’s primary language on the document element; use locallangattributes for passages in another language. - Assuming Google needs
langto detect language. Keep it for accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all., browsers, Bing, and standards—not as a Google ranking lever.
A screen reader uses the wrong pronunciation
Likely cause: missing, invalid, or incorrect root language; foreign-language passages may also be unmarked. Fix: set the correct BCP 47 value on <html> and local overrides where language changes. Confirm: inspect the accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. tree and test with the relevant screen reader voice.
Every localized page says lang="en"
Likely cause: a hard-coded base template or locale mapping that never reaches the document shell. Fix: derive the root value from the route/content locale on the server or at build time. Confirm: crawl representative locale URLs and compare declared language with visible content.
lang and hreflang disagree
Likely cause: separate locale maps, invalid region codes, or a template fallback. Fix: use one normalized locale configuration while preserving the different purposes of the two signals. Confirm: each page declares its own content language and its alternate links point to the correct reciprocal variants.
Browser translation prompts are wrong
Likely cause: the declared language conflicts with the dominant visible content or mixed-language blocks are not scoped. Fix: correct the root declaration and mark substantial passages with their own lang. Confirm: browser and accessibility checks identify the intended primary language.
Patrick's relevant free tools
- Heading Structure Checker — Paste HTML or fetch a public page to visualize its heading hierarchy, catch skipped levels and empty headings, compare its H1 with the title, and preview a table of contents.
- Link Analyzer — Inspect a page’s links and linked resources with source locations, calibrated anchor-text findings, and optional batched HTTP status checks.
- Image SEO Checker — Audit raw HTML image signals: alt attributes, lazy-loading hints, fetch priority, source formats, and ImageObject markup.
Tools for language declarations
- On-Page SEO Checker surfaces the raw document language alongside other HTML signals.
- hreflang Generator + Linter checks alternate-language codes and relationships; use it alongside, not instead of, the root
langaudit. - Browser DevTools shows the root
<html lang>value and accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. tree used by assistive technology. - A crawlerA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index. with XPath extraction can compare the declaration across locale templates:
string(/html/@lang).
Resources worth your time
My related writing
- Hreflang: The Easy Guide for Beginners — the hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. deep dive I’m credited on, including the “HreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. and HTML lang mismatch” audit issue that ties
langand hreflang together. - The Beginner’s Guide to Technical SEO — where markup and international signals fit in the bigger picture.
My speaking
- How Search Works (SlideShare) — my walkthrough of crawlingCrawling is how search engines use automated bots (like Googlebot and Bingbot) to discover URLs and download pages. A page has to be crawlable to be indexed, but crawling on its own isn't a ranking factor., renderingTurning HTML, CSS, and JavaScript into the final visual page and DOM., indexingStoring a crawled page in the search index so it can appear in results. Crawled is not the same as indexed — Google selects what to keep, and indexing isn't guaranteed., and ranking, including how Google reads (and normalizes) your markup. (My standing disclaimer applies: “This is my understanding of systems… not going to be 100% complete or accurate.”)
Official
- Google — Localized Versions of your Pages and Translated Google Search Results.
- Bing — How To Tell Bing Your Website’s Country and Language (2011, via Wayback Machine).
From around the industry
- MDN —
langglobal attribute — the definitive technical reference: BCP 47, empty-vs-absent, inheritance. - W3C — Declaring language in HTML — the standards-body how-to, including mixed-language pages.
- Deque — axe rule
html-has-lang— the accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. rule behind LighthouseLighthouse is Google's free, open-source tool that audits a page under simulated lab conditions and scores it 0–100 across Performance, Accessibility, Best Practices, and SEO. It's lab data — useful for debugging, not a ranking signal.’s audit. - WebAIM Million — the annual survey with the current “missing document language” failure rate.
- Adrian Roselli — On Use of Lang Attribute — the deep accessibility catalog of what
langactually affects. - Manuel Matuzovic — the lang attribute: browsers telling lies — the ORF.at
lang="en"-on-German auto-translate case study. - Google: We Ignore The HTML lang Attribute (Search Engine Roundtable) — the full Mueller “almost always wrong” quote.
- r/TechSEO — the community for markup, international, and audit debugging.
Test yourself: The HTML lang Attribute
Five quick questions on what lang does and how it differs from hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others.. Pick an
answer for each, then check.
HTML lang Attribute
The HTML lang attribute is a global attribute — most importantly set on the <html> element (<html lang="en">) — that declares the natural language of THIS document's content using a BCP 47 language tag (en, es, en-US, pt-BR). It's distinct from hreflang, which points to alternate-language URLs. Google ignores lang for language detection; Bing uses it as a fallback targeting signal; and it drives accessibility (screen-reader pronunciation) and the browser auto-translate prompt.
Related: Hreflang, Semantic HTML, HTML SEO
HTML lang Attribute
The HTML lang attribute is a global HTML attribute that declares the natural language of the text content on the document it’s set on. It matters most on the root element — <html lang="en"> — but it can be applied to any element to mark a language change within a page (<span lang="fr">c'est la vie</span> inside an otherwise English page).
Its value is a BCP 47 language tag: a language subtag alone (en, es, de) or language-plus-region (en-US, en-GB, pt-BR, zh-Hans). Made-up three-letter codes (eng) or full language names aren’t valid, and an explicitly empty lang="" means “unknown” — a different state from omitting the attribute entirely.
It is easy to confuse with hreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others., but the two do unrelated jobs. lang is a single value that says “this page’s content is written in this language.” HreflangHreflang is an annotation (in HTML, HTTP headers, or XML sitemaps) that tells search engines which language and optional region a page targets, and which alternate versions exist. It only works when every page in the cluster references all the others. is a set of cross-page annotations that say “here are the other URLs that hold alternate language/region versions of this page.” One is a self-description; the other is a map to other pages.
For search, lang is not a strong direct Google signal — Google states it uses algorithms, not lang or hreflang, to detect a page’s language. Bing is the opposite case: it uses <html lang> as a fallback document-location signal (behind the content-language meta tag). Beyond search, lang is a required accessibilityWeb accessibility means designing sites so people with disabilities can use them, per the W3C's WCAG guidelines. It overlaps with SEO in specific, checkable ways — alt text, heading structure, descriptive link text, captions, and page speed all serve both audiences — but Google has said accessibility itself is not a ranking factor, and most WCAG success criteria (keyboard focus order, ARIA live regions, form labels) have no SEO effect at all. attribute (WCAG 3.1.1) that lets screen readers pick the correct pronunciation, and it’s one of the signals browsers use when deciding whether to offer an auto-translate prompt.
Related: Hreflang, Semantic HTML, HTML SEO
Build-time retrieval analysis plus live signals for this exact article. The automatic chunk report includes a deterministic readiness score and is ready without a model download.
Search Console
sampleGA4 traffic (28d)
sampleCloudflare traffic (7d)
sampledCrUX field data (28d, phone)
sampleGoogle NLP entities
localChangelog
Updated Jul 18, 2026.
Editorial summary and recorded change details.Summary
Minor precision pass: qualified assistive-technology behavior as varying by tool/voice, distinguished a syntactically valid lang tag from a correct one, and added a bullet distinguishing the in-document lang declaration from the HTTP Content-Language header. No facts changed.
Change details
-
Added a qualifier noting screen-reader/browser behavior varies by tool, browser, and voice rather than being identical everywhere.
-
Clarified that a syntactically well-formed BCP 47 tag can still be the wrong value for the actual content (validity is a floor, not a correctness guarantee).
-
Added a bullet distinguishing the in-document lang attribute (with its inheritance/override model) from the unrelated HTTP Content-Language response header.
Full comparison unavailable — no prior snapshot was archived for this revision.