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.

Première publication : 2 juil. 2026 · Dernière mise à jour : 3 août 2026 · Advanced
Langues
1 indice probant sur cette page

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 — lang declares the natural language of ce document (<html lang="en">, or a region variant like en-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 HTML lang attribute 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 with lang="es-x-mtfrom-en". Définir a valid valeur, garder it consistent with hreflang, and kill the boilerplate lang="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 Page

Three 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 pas en-UK (the region subtag pour the United Kingdom is GB). 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 — reset lang locally 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 HTTP Content-Language réponse header: que header describes transport metadata à propos de la réponse, pas the parsed document, and it isn’t a substitute pour lang quand 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?

  • lang is 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.

`lang` describes this document for browsers and assistive technology; hreflang maps alternate URLs for search-result routing. Source : Google Search Central

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:

  1. The content-language meta tag in the <head> (<meta http-equiv="content-language" content="en-us">).
  2. 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>.”
  3. ccTLD.
  4. 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.

Caveat: ce is a 2011 post, now delisted from Bing’s current blog archive. I’m citing it via the Wayback Machine capture; aucun newer Bing statement supersedes it que I pourrait trouver, so I treat the mechanism as encore current — but its age is worth flagging honestly plutôt que presenting it as fresh guidance.

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.

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

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.

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 remember GB, pas UK.
  • Définir it on the element que changements, aussi. Pour an embedded foreign phrase in an sinon single-language page, reset lang locally: <span lang="fr">c'est la vie</span>. Unset descendants inherit the nearest ancestor’s lang, 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 lang dit es-MX but its hreflang annotation pour que même URL dit en, 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 the lang half of que comparison, but a mismatch encore signals que something is misconfigured — qui is pourquoi site audit outils flag it.

Courant myths

  • “Correct lang will improve my Google rankings.” Aucun. Google states it doesn’t utiliser lang pour 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.
  • lang and hreflang are basically the same.” Aucun — lang describes lune page it’s on; hreflang points to autre URLs. Une page peut have a correct lang and aucun hreflang, or correct hreflang and a incorrect lang.
  • “No search engine cares about lang.” Bing explicitly fait (as a fallback behind content-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 lang gives 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.

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.