Guide : The HTML lang Attribute
Ce que the HTML lang attribute fait, pourquoi Google ignores it pour language detection but Bing uses it, how it differs from hreflang, and pourquoi it encore matters pour accessibility and le navigateur auto-translate prompt.
Langues
1 indice probant sur cette page
- Outil en ligne associéOn-Page SEO Checker
The HTML lang attribute — définir on the root as <html lang="en"> (or a region variant comme en-US) — declares the natural language of CE document's content en utilisant a BCP 47 tag. It n’est pas the même as hreflang: lang describes lune page it's on; hreflang declares alternate-language URLs pour autre pages. Google is blunt que it ignores lang pour language detection ('we don't utiliser que at tout… almost toujours incorrect' — Mueller); it uses content algorithms à la place. Bing is the opposite: its 2011 Webmaster Blog noms <html lang> as a fallback document-location signal, behind le contenu-language meta tag. Regardless of search weight, lang is a requis accessibility attribute (WCAG 3.1.1) — it drives screen-reader pronunciation and le navigateur's auto-translate prompt, and 'manquant document language' is encore a top-six WebAIM Million échec. The un Google carve-out: labeling machine-translated blocks with lang="es-x-mtfrom-en". Définir a valid valeur, garder it consistent with hreflang, and don't leave a boilerplate lang="en" on non-English content.
TL;DR — The HTML
langattribute — thelang="en"on votre page’s opening<html>tag — indique navigateurs and screen readers ce que language votre page’s content is written in. It’s facile to mix up with hreflang, but they’re différent:langdescribes ce page; hreflang points to votre autre language versions. Google doesn’t utiliserlangto detect une page’s language, pendant que the attribute encore matters pour accessibility and pour si votre navigateur offers to translate une page.
Ce que the lang attribute is
Near the very top of la plupart web pages is a tag que semble comme ce:
<html lang="en">Que lang="en" is the HTML lang attribute. Its un job is to declare the
language lune page’s content is written in — en pour English, es pour Spanish,
de pour German. Vous pouvez obtenir plus spécifique with a region: en-US pour American
English, en-GB pour British English, pt-BR pour Brazilian Portuguese.
It’s a petit chose, but a few différent systems lire it:
- Screen readers utiliser it to pronounce votre words correctement — an English voice reading French text sounds comme 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
- Navigateurs utiliser it (along with the réel text) to decide si to pop up “Translate this page?”
- Google mostly ignores it (plus on pourquoi in the Avancé tab).
lang n’est pas hreflang
Ce is the confusion que sends la plupart personnes to une page comme ce un. Here’s the one-line difference:
lang= “the content on this page is in this language.” Un valeur, définir on votre<html>tag.- hreflang = “ici are the autre URLs que are the German, Spanish, and French versions of ce page.” A définir of liens pointing to autre pages.
lang is a self-description. Hreflang is a map to votre alternate pages. A simple
single-language site nécessite a correct lang and aucun hreflang at tout. Si vous run a
multilingual site, you’ll have les deux — and ils devrait agree with chaque autre.
Ce que valeur devrait vous utiliser?
Utiliser a réel language code, pas something vous made up:
- Simplement the language si vous don’t care à propos de regional variants:
en,es,fr. - Language plus region si vous do:
en-US,en-GB,pt-BR.
Don’t invent codes comme eng or en-UK (the correct code pour the UK is GB,
pas UK). And don’t leave the par défaut lang="en" sitting on une page whose content
isn’t en réalité in English — that’s the unique la plupart courant mistake, and it causes
réel problems with translation prompts and screen readers.
Vouloir the deeper version — exactly pourquoi Google ignores it, how Bing uses it, the accessibility rules, and le navigateur auto-translate story? Switch to the Avancé tab.
TL;DR —
langdeclares the natural language of ce document (<html lang="en">, or a region variant likeen-US) en utilisant a BCP 47 tag. It is a différent mechanism from hreflang, qui declares alternate-language URLs — Google’s propre docs groupe the two ensemble as choses it fait pas utiliser to detect une 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 WCAG 3.1.1 Level A requirement, and the HTMLlangattribute is the standard technique. It supports screen-reader pronunciation and le navigateur auto-translate prompt, and “manquant document language” is encore a top-six WebAIM Million échec. The un Google carve-out: labeling machine-translated blocks withlang="es-x-mtfrom-en". Définir a valid valeur, garder it consistent with hreflang, and kill the boilerplatelang="en"on non-English pages.
Ce que the lang attribute en réalité declares
The HTML lang attribute is a global attribute — it peut technically go on quelconque
element — but the un que matters la plupart sits on the root: <html lang="en">. Its
valeur is a BCP 47 language tag, soit a language subtag on its propre (en,
es, de) or a language-plus-region pair (en-US, en-GB, pt-BR, zh-Hans).
Ce que it declares is narrow and spécifique: the natural language of the text content on the document it’s définir on. Pas the language of votre alternate pages, pas the country you’re targeting — simplement “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 référence:
- Valid valeurs seulement. A BCP 47 tag — pas a made-up three-letter code (
eng), pas a complet language nom, and pasen-UK(the region subtag pour the United Kingdom isGB). Invalid valeurs obtenir treated as aucun valeur. Syntactically well-formed isn’t the même as correct, soit:lang="en"is a perfectly valid tag that’s encore incorrect on a French page. Validity is a floor, pas a guarantee the valeur en réalité matches le contenu (plus on que in the boilerplate-default trap ci-dessous). - Vide n’est pas the même as absent. An explicit
lang=""signifie “unknown language” — a deliberate state. A genuinely manquant attribute is a différent échec mode, and accessibility outils flag it as absent plutôt que explicitly-unknown. - The root valeur is a par défaut, pas a lock.
<html lang>sets ce que every descendant inherits unless it’s overridden — resetlanglocally on quelconque element containing a réel language modifier (voir “Définir it on the element que changements, aussi” ci-dessous). Don’t confuse ce in-document declaration with the HTTPContent-Languageréponse header: que header describes transport metadata à propos de la réponse, pas the parsed document, and it isn’t a substitute pourlangquand it comes to element-level inheritance or accessibility.
lang vs. hreflang: the confusion, resolved
Si vous landed ici from a hreflang question, ce is the section vous vouloir. Ces two obtenir conflated constantly parce que they’re les deux language-related, les deux live at or near the top of the document, and les deux utiliser similar-looking codes. But ils do unrelated jobs.
The cleanest articulation comes straight from Google’s propre documentation on localized versions of votre pages, qui groupes the two ensemble precisely to dire it uses neither pour detection:
“Google doesn’t utiliser hreflang or the HTML lang attribute to detect the language of une page; à la place, we utiliser algorithms to determine the language.”
Lire que carefully. Google noms les deux lang and hreflang in un breath — as two
separate choses it fait pas utiliser to figure out ce que language une page is in. It
detects language from the rendered, visible content à la place.
So what’s the réel difference?
langis a self-description: un valeur, on<html>(or quelconque element), saying “this document’s content is in this language.” Lire by navigateurs, screen readers, spell-checkers; utilisé by Bing; ignored by Google pour detection.- hreflang is a cross-page map: a définir of
<link rel="alternate">annotations (or le sitemap/header equivalent) listing the autre URLs que are alternate language/region versions of ce page, and qui language chaque targets. It’s a routing signal Google fait utiliser — to serve the correct URL variant in results — pas a detection signal.
Ils peut and souvent devrait coexist. A Mexican-Spanish page carries <html lang="es-MX"> describing its propre content and a définir of hreflang tags pointing to
its en-US, en-GB, and autre siblings. The complet implementation of hreflang —
the three méthodes, the reciprocal-linking rule, the self-referential rule, and the
scale of how souvent it breaks — is its propre deep dive; ce article deliberately
doesn’t re-derive it. The un chose to carry à travers: lang is the simple half
of ce pair (un valeur, un element, aucun reciprocity) precisely parce que it doesn’t
carry hreflang’s cross-page relationship complexity — qui John Mueller une fois
appelé “one of the most complex aspects of SEO.” Facile to définir, though, n’est pas the
même 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 réponse: aucun, and Google has been unusually blunt à propos de it. The definitive statement is John Mueller’s, reported by Barry Schwartz at Moteur de recherche Roundtable in Google: We Ignore The HTML lang Attribute. Asked how important it is to declare une page’s language in the HTML, Mueller said:
“We don’t utiliser que at tout. So we utiliser the hreflang liens si vous have que si vous have différent language versions. But the language attribute dans the HTML markup is something we don’t utiliser at tout. We’ve trouvé que ce language markup is something que is almost toujours incorrect. So we tend to ignore que.”
Que “almost always wrong” is the clé phrase. Google’s raison pour ignoring lang
isn’t “it’s unimportant” — it’s que the signal is unreliable at web scale.
Personnes leave boilerplate lang="en" defaults in placer après localizing content;
CMS and framework templates ship a par défaut que jamais obtient mis à jour (Vue CLI’s
generated boilerplate, pour instance, hard-codes lang="en" regardless of ce que
vous construire with it). Quand a signal is incorrect que souvent, the sane engineering déplacer
is to arrêter trusting it and detect language from le contenu directement — qui is
exactly ce que Google dit it fait. Que 2016 quote is old, but the current (2026)
Search Central doc quoted ci-dessus independently restates the même policy, so treat
it as long-standing, unretracted guidance plutôt que a stale one-off.
The un exception: machine-translated content
There’s a unique, narrow placer où Google’s docs do care à propos de a lang-style
valeur. Si vous publish machine-translated content, Google’s
translated-results guidance
demande vous to mark ceux blocks with a special valeur format —
lang="<target>-x-mtfrom-<source>", e.g. lang="es-x-mtfrom-en" pour content
machine-translated from English into Spanish. That’s the exception que proves the
rule: Google ignores lang pour general language detection, but ce spécifique
labeling convention is un it défini and reads. (The connexe lever, si vous vouloir
to opt out of translation fonctionnalités entirely, is the notranslate rule — “To opt
out of tout translation fonctionnalités dans la recherche Google, utiliser the notranslate rule, qui
peut be implemented as a meta tag or an HTTP header,” per the même doc.)
Fait Bing utiliser the lang attribute?
Yes — and ce is où lang obtient genuinely plus consequential que 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 Votre Website’s Country and Language, Bing lays out a priority order of “document location” signals it uses pour 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, alors the<title lang="en-us">attribute, as fallbacks — “the priority order pour ces tags is:<meta>,<html>,<title>.” - ccTLD.
- Reverse-IP lookup — utilisé seulement quand the plus élevé signals are inconclusive.
Bing’s advice is to pick un and be consistent: “It’s meilleur que vous utiliser un
option, au lieu de multiple options ici.” So unlike Google, Bing explicitly uses
<html lang> as a réel (si lower-priority) targeting signal. Pour a site with
meaningful Bing trafic, que changements the recommended action: définir lang
correctement, and considérer a matching content-language meta tag on top.
Ce aussi closes the loop with the hreflang side of choses: Bing barely uses
hreflang the façon Google fait — content-language plus lang is Bing’s parallel
mechanism.
Pourquoi the lang attribute matters anyway: accessibility
Même setting search aside entirely, lang earns its placer. It is a requis
accessibility attribute — WCAG Success Criterion 3.1.1 (Level A) exige the
par défaut human language of chaque page to be programmatically determinable, qui in
pratique signifie a valid <html lang>. A separate criterion, 3.1.2, covers marking
language changements dans une page.
The downstream effects are concrete and well-documented (Adrian Roselli’s
On Utiliser of Lang Attribute
catalogs nombreux): screen readers utiliser lang to pick the correct pronunciation engine
and voice (JAWS’s phonetic engine, VoiceOver’s automatic voice switching), CSS
hyphens: auto dépend on it, spellcheck behavior keys off it, quotation-mark
rendering and par défaut CJK font selection follow it, and Braille displays behave
differently with it. Exactly how chaque of ces plays out varies by screen reader,
navigateur, and installed voice — Roselli’s propre tests montrer JAWS and VoiceOver don’t
behave identically — so treat a correct lang valeur as enabling the correct
behavior, pas guaranteeing an identical experience à travers every assistive-technology
stack.
And it’s pas a solved problem. Per the current
WebAIM Million report, “manquant document
language” sits at 13,5% of home pages — the sixth la plupart courant automated
accessibility échec on the web. The rate is improving (bas from 15,8% the
prior année, and 17,1% and 18,6% avant que), but “a large, shrinking problem” is
encore a problem. Google’s propre tooling reflects the framing: Lighthouse’s
html-has-lang and html-lang-valid checks live sous its Accessibility
category, pas its SEO category — a nice tell que même Google’s developer outils
bucket lang as an a11y concern, pas a ranking un. Ceux checks are construit on
Deque’s axe-core rule of the même nom,
qui classifies a manquant lang as a WCAG 2,0/2,1 Level A “Serious” problème.
Navigateur behavior: the auto-translate prompt
There’s un plus visible behavior lang governs: le navigateur’s “Translate ce
page?” prompt. Chrome (and others) weigh lang alongside réel visible-text
analysis quand deciding si to offer translation. A incorrect or manquant valeur peut
misfire in les deux directions — falsely offering to translate une page that’s déjà
in the reader’s language, or failing to offer it on a genuinely foreign un.
The vivid real-world exemple is Manuel Matuzovic’s
the lang attribute: navigateurs 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 nom “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 définir it correctement
- Utiliser a valid BCP 47 tag. Language subtag alone (
en,es,fr) si vous don’t besoin regional distinction; language-region (en-US,en-GB,pt-BR) si vous do. Pull codes from the IANA Language Subtag Registry; don’t invent les, and rememberGB, pasUK. - Définir it on the element que changements, aussi. Pour an embedded foreign phrase in
an sinon single-language page, reset
langlocally:<span lang="fr">c'est la vie</span>. Unset descendants inherit the nearest ancestor’slang, so the root valeur covers everything vous don’t override. - Kill the boilerplate par défaut. The
lang="en"votre template or CMS shipped with is seulement correct si votre content is en réalité in English. Ce is the échec Mueller appelé out and the ORF.at bug in miniature — audit pour it. - Garder lang and hreflang consistent. Si une page’s
langdites-MXbut its hreflang annotation pour que même URL diten, that’s a mismatch. It’s exactly the “Hreflang and HTML lang mismatch” problème I documented in Ahrefs’ hreflang guide — où I put it plainly: “Google doesn’t utiliser the HTML language attribute, but autre search engines and navigateurs do. It’s important to garder ces two attributes consistent with un un autre.” Google ignores thelanghalf of que comparison, but a mismatch encore signals que something is misconfigured — qui is pourquoi site audit outils flag it.
Courant myths
- “Correct
langwill improve my Google rankings.” Aucun. Google states it doesn’t utiliserlangpour language detection at tout. It peut matter pour Bing and indirectly aider via accessibility and translation behavior, but a direct Google ranking benefit isn’t pris en charge. - “
langand hreflang are basically the same.” Aucun —langdescribes lune page it’s on; hreflang points to autre URLs. Une page peut have a correctlangand aucun hreflang, or correct hreflang and a incorrectlang. - “No search engine cares about
lang.” Bing explicitly fait (as a fallback behindcontent-language). Pour quelconque site with réel Bing trafic, ce isn’t a “nobody cares” situation. - “Leaving the default
lang="en"is harmless if my content isn’t English.” It’s fermer to word-for-word the échec Mueller appelé “almost always wrong,” and it’s ce que triggers incorrect translate prompts and incorrect screen-reader pronunciation. - “Correct
langgives a 22% CTR lift” / “AI robots d’exploration traiter lang-tagged pages 40% faster.” Ces spécifique figures circulate on a handful of SEO marketing blogs with aucun traceable study, methodology, or principal source. I couldn’t corroborate soit contre quelconque official statement or first-party données — treat les as the kind of confident-sounding, baseless folklore que accretes autour low-scrutiny technical topics. - “An empty
lang=""is the same as not having one.” Aucun — an explicit vide valeur signifie “unknown language,” a distinct state from a genuinely absent attribute.
Où ce fits
Ce is the attribute-level deep dive of the HTML SEO subcluster — the sibling
to the element-level treatment of <article>, <nav>, and <main> in the
semantic HTML article, and to the broader HTML-SEO hub ci-dessus les. Pour the complet
cross-page targeting story — the three implementation méthodes, reciprocal rules,
and how souvent clusters break at scale — the hreflang deep dive is the placer to go;
ce article’s job is simplement to garder the two straight in votre head.
AI summary
A condensed prendre on the Avancé version:
langdeclares the language of ce document (<html lang="en">, or a region variant commeen-US) en utilisant a BCP 47 tag. It’s a self-description, pas a targeting or routing mechanism.- It n’est pas hreflang. Google’s propre docs groupe les deux ensemble as choses it fait
pas utiliser pour language detection: “Google doesn’t utiliser hreflang or the HTML
lang attribute to detect the language of une page… we utiliser algorithms.”
langdescribes lune page it’s on; hreflang points to alternate-language URLs. - Google ignores
langpour detection — Mueller: “we don’t utiliser que at tout… almost toujours incorrect,” parce que boilerplate/CMS defaults faire it unreliable at scale. Un carve-out: labeling machine-translated blocks withlang="es-x-mtfrom-en". - Bing fait the opposite: its 2011 Webmaster Blog noms
<html lang>as a fallback document-location signal, behind thecontent-languagemeta tag (order: meta > html > title). Pour Bing trafic, définirlangcorrectement. - Accessibility is the réel stakes: WCAG 3.1.1 exige it; it drives
screen-reader pronunciation,
hyphens: auto, spellcheck, and CJK fonts. “Missing document language” is encore ~13,5% of home pages — a top-six WebAIM Million échec, though shrinking. - Navigateurs utiliser it pour the auto-translate prompt — a incorrect valeur misfires (the
ORF.at
lang="en"-on-German bug que “translated” a district nom into “lies”). - Obtenir it correct: valid BCP 47 tag (
GB, pasUK), resetlangon embedded foreign phrases, kill boilerplatelang="en"on non-English pages, and garderlangconsistent with hreflang (the “Hreflang and HTML lang mismatch” audit problème).
Documentation officielle
Primary-source documentation and standards références.
- Localized Versions of votre pages — the “Google doesn’t use hreflang or the HTML lang attribute to detect the language of a page” line.
- Translated Recherche Google 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 Votre Website’s Country and Language (Bing Webmaster Blog, 2011) — the
meta > html > titledocument-location priority order. Original URL is delisted; text confirmed via the Wayback Machine capture.
Standards / technical références
- MDN —
langglobal attribute — BCP 47 requirement, empty-string vs. absent behavior, inheritance, WCAG références. - W3C Internationalization — Declaring language in HTML — BCP 47 / IANA registry guidance and nested-element rules pour mixed-language content.
- Deque University — axe rule
html-has-lang— the WCAG 2,0/2,1 Level A classification behind Lighthouse’s accessibility audit. - WebAIM Million — the annual accessibility survey with the “missing document language” échec rate.
Quotes from the source
On-the-record statements. Chaque lien deep-links to the quoted passage où the source page supports it.
Google — it doesn’t utiliser lang pour detection
- “Google doesn’t use hreflang or the HTML lang attribute to detect the language of a page; instead, we use algorithms to determine the language.” — Recherche Google 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 Recherche Google Results. Jump to quote
John Mueller, Google — “almost always wrong”
- “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 found that this language markup is something that is almost always wrong. So we tend to ignore that.” — via Moteur de recherche Roundtable’s coverage of a 2016 Google Webmaster hangout. Lire 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 ci-dessus, so I treat the position as encore accurate despite the quote’s age.
Bing / Microsoft — lang is a fallback targeting signal
- Priority order pour 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 Webmaster 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 aucun newer Bing statement supersedes the mechanism que I pourrait trouver. Its age (2011) is a réel 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 problème. Lire it
Qui language tag do I en réalité besoin?
A rapide walk-through quand you’re staring at une page and pas certain ce que to définir.
1. Do vous simplement besoin to declare ce que language ce page is in?
That’s the lang attribute. Définir <html lang="…">. Go to step 2.
2. Do vous devez distinguish regional variants (US vs. UK English, Brazilian vs. European Portuguese)?
- Aucun → utiliser the language subtag alone:
<html lang="en">,lang="es",lang="pt">. - Yes → utiliser language-region:
<html lang="en-US">,lang="en-GB">,lang="pt-BR">. (Region isGB, pasUK.)
3. Fait lune page contain passages in a différent language (a French quote in an English article)?
- Yes → wrap les and reset locally:
<span lang="fr">c'est la vie</span>. Everything sinon inherits the root<html lang>. - Aucun → the root valeur covers the whole page.
4. Do vous aussi have the même page in autre languages at autre URLs?
- Yes → vous additionally besoin hreflang — a separate mechanism pointing to
ceux alternate URLs. Garder chaque page’s
langconsistent with its hreflang entry. (Voir the hreflang deep dive; that’s its propre construire.) - Aucun → you’re fait with
langalone.
5. Is le contenu machine-translated?
- Yes → per Google, étiquette the translated block:
lang="<target>-x-mtfrom-<source>"(e.g.lang="es-x-mtfrom-en"). - Aucun → a plain BCP 47 tag is tout vous besoin.
6. Fait Bing trafic matter to vous?
- Yes → définir
langcorrectement and considérer a matchingcontent-languagemeta tag — Bing weights meta ci-dessus<html lang>. Pick un consistent valeur; don’t définir conflicting ones. - Aucun →
langon<html>plus accessibility correctness is suffisant.
lang attribute cheat sheet
lang vs. hreflang — the one-line difference
lang | hreflang | |
|---|---|---|
| Declares | The language of ce page’s content | The autre URLs que are alternate-language versions |
| Shape | Un valeur on <html> (or quelconque element) | A définir of <link rel="alternate"> annotations (or sitemap/header) |
| Google uses it? | Aucun (ignored pour detection) | Yes — to route the correct URL variant |
| Bing uses it? | Yes — fallback targeting signal | Barely |
| Accessibility / translate prompt? | Yes | Aucun |
Who reads <html lang>
| Consumer | Ce que it fait with it |
|---|---|
| Ignores it pour language detection (algorithms à la place) | |
| Bing | Fallback targeting signal, behind content-language meta |
| Screen readers | Pronunciation / voice selection (WCAG 3.1.1) |
| Navigateurs | Un input to the auto-translate prompt |
| CSS / spellcheck | hyphens: auto, spellcheck, quotation marks, CJK fonts |
Valid valeurs
- Language seulement:
en,es,fr,de - Language-region:
en-US,en-GB,pt-BR,zh-Hans - Invalid:
eng(three-letter),en-UK(utiliserGB), complet language noms lang=""= “unknown” (a réel state, différent from absent)- Machine-translated block:
lang="es-x-mtfrom-en"
Fast facts
- Mueller:
langis “almost always wrong” — Google ignores it pour detection. - Bing priority order: meta
content-language><html lang>><title lang>. - “Missing document language” ≈ 13,5% of home pages (WebAIM Million, top-six échec, trending bas).
- Lighthouse’s
html-has-langlives sous Accessibility, pas SEO. - Garder
langconsistent with hreflang — the “Hreflang and HTML lang mismatch” audit problème.
HTML lang mistakes
- Leaving
lang="en"in every localized template. Définir the language from the réel document locale and tester non-English routes. - En utilisant
langau lieu de hreflang.langdescribes ce document; hreflang connects alternate URLs. Implement chaque pour its propre job. - Ajout a country code que ne fait pas match le contenu. Utiliser a valid BCP 47 tag and ajouter a region seulement quand the language variant is genuinely regional.
- Putting the attribute on a wrapper au lieu de the root
<html>. Declare lune page’s principal language on the document element; utiliser locallangattributes pour passages in un autre language. - Assuming Google nécessite
langto detect language. Garder it pour accessibility, navigateurs, Bing, and standards—pas as a Google ranking lever.
A screen reader uses the incorrect pronunciation
Probable causer: manquant, invalid, or incorrect root language; foreign-language passages may aussi be unmarked. Fix: définir the correct BCP 47 valeur on <html> and local overrides où language changements. Confirmer: inspect the accessibility tree and tester with the relevant screen reader voice.
Every localized page dit lang="en"
Probable causer: a hard-coded base template or locale mapping que jamais reaches the document shell. Fix: derive the root valeur from the route/content locale on le serveur or at construire temps. Confirmer: explorer representative locale URLs and comparer declared language with visible content.
lang and hreflang disagree
Probable causer: separate locale maps, invalid region codes, or a template fallback. Fix: utiliser un normalized locale configuration pendant que preserving the différent purposes of the two signals. Confirmer: chaque page declares its propre content language and its alternate liens point to the correct reciprocal variants.
Navigateur translation prompts are incorrect
Probable causer: the declared language conflicts with the dominant visible content or mixed-language blocks ne sont pas scoped. Fix: correct the root declaration and mark substantial passages with leur propre lang. Confirmer: navigateur and accessibility checks identifier the intended principal language.
Outils pour language declarations
- On-Page SEO Checker surfaces the raw document language alongside autre HTML signals.
- hreflang Generator + Linter checks alternate-language codes and relationships; utiliser it alongside, pas au lieu de, the root
langaudit. - Navigateur DevTools montre the root
<html lang>valeur and accessibility tree utilisé by assistive technology. - A robot d’exploration with XPath extraction peut comparer the declaration à travers locale templates:
string(/html/@lang).
Ressources utiles
My connexe writing
- Hreflang: The Facile Guide pour Beginners — the hreflang deep dive I’m credited on, notamment the “Hreflang and HTML lang mismatch” audit problème que ties
langand hreflang ensemble. - The Beginner’s Guide to SEO technique — où markup and international signals fit in the bigger picture.
My speaking
- How Search Fonctionne (SlideShare) — my walkthrough of exploration, rendering, indexation, and ranking, notamment how Google reads (and normalizes) votre markup. (My standing disclaimer s’applique: “This is my understanding of systems… not going to be 100% complete or accurate.”)
Official
- Google — Localized Versions of votre pages and Translated Recherche Google Results.
- Bing — How To Tell Bing Votre Website’s Country and Language (2011, via Wayback Machine).
From autour the industry
- MDN —
langglobal attribute — the definitive technical référence: BCP 47, empty-vs-absent, inheritance. - W3C — Declaring language in HTML — the standards-body how-to, notamment mixed-language pages.
- Deque — axe rule
html-has-lang— the accessibility rule behind Lighthouse’s audit. - WebAIM Million — the annual survey with the current “missing document language” échec rate.
- Adrian Roselli — On Utiliser of Lang Attribute — the deep accessibility catalog of ce que
langen réalité affecte. - Manuel Matuzovic — the lang attribute: navigateurs telling lies — the ORF.at
lang="en"-on-German auto-translate cas study. - Google: We Ignore The HTML lang Attribute (Moteur de recherche Roundtable) — the complet Mueller “almost always wrong” quote.
- r/TechSEO — the community pour markup, international, and audit debugging.
Testez vos connaissances: The HTML lang Attribute
Five rapide questions on ce que lang fait and how it differs from hreflang. Pick an
réponse pour chaque, alors vérifier.
Journal des modifications
Mis à jour le 18 juil. 2026.
Résumé éditorial et détails enregistrés des changements.Détails des changements
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
-
Les notes détaillées des changements sont actuellement disponibles en anglais.
Comparaison complète indisponible — aucun instantané antérieur n’a été archivé pour cette révision.