Business owners who expand into a second country often ask me: “If I set the right language code in my HTML, will Google show my Spanish pages to Spanish speakers?” It is a fair question. There is a tag that literally says what language the page is in. Surely Google reads it?
It doesn’t. Google has said clearly that it ignores the HTML lang attribute when working out a page’s language. And yet I still tell every client to set it correctly. That sounds like a contradiction, so let me explain it.
In this guide I will cover what the lang attribute is, how Google really detects language, how lang differs from hreflang and the Content-Language header, why screen readers depend on it and how to fix wrong values across a site. In brief: lang is not a Google ranking tool, but it is a quality and accessibility basic, and other search engines and tools do read it.
What the HTML lang attribute is
The lang attribute is a short code that tells software which human language the text is written in. It usually sits on the very first tag of the page:
<html lang="en">
It is one of a handful of small declarations at the top of every page, alongside the character set and the viewport meta tag. Every element inside the page inherits that language unless you say otherwise. If a paragraph is in French, you can mark just that paragraph:
<p lang="fr">Livraison gratuite dès 50 €.</p>
The W3C, which writes web standards, is direct about this in its guide to declaring language in HTML:
“Always use a language attribute on the html tag”
— W3C Internationalization, Declaring language in HTML
The values follow a standard called BCP 47. You can use a simple language code, or add a region or script:
enfor English,esfor Spanish,hifor Hindien-GBfor British English,es-MXfor Mexican Spanishzh-Hansfor Chinese in Simplified script,zh-Hantfor Traditional script
According to MDN, if you leave the value empty (lang=""), the language is treated as unknown. If you leave the attribute out entirely and nothing else declares a language, the result is also unknown.
How Google actually works out a page’s language
Here is the part that surprises people. Google doesn’t use the lang attribute at all. Its guide to managing multi-regional and multilingual sites says:
“Google uses the visible content of your page to determine its language. We don’t use any code-level language information such as lang attributes”
— Google Search Central, Managing multi-regional and multilingual sites
Google’s list of meta tags and attributes it supports repeats the point in its section on unsupported items: Google Search detects language from the text on the page. For a wider look at what Google reads and ignores in your <head>, see my guide to meta tags Google supports.
Why would Google ignore it? Because it is so often wrong. Many sites copy a template with lang="en" and never change it, even when the page is in German or Tamil. Reading the actual text is more reliable.
What this means in practice:
- Your words decide your language in Google. If the main content is Spanish, Google treats the page as Spanish, whatever the tag says.
- Mixed-language templates confuse things. Google advises using one language for both content and navigation on a page and avoiding side-by-side translations.
- Translating only the menu doesn’t make a page local. Google warns that translating only the boilerplate (the repeated template text) can create a bad experience when the same main content appears in several results. I cover this in boilerplate content and SEO.
If international SEO is new to you, start with our lesson on international SEO.
Lang vs hreflang vs Content-Language
These three get mixed up all the time. They do different jobs, and only one of them is used by Google to choose between language versions.
lang attribute | hreflang annotation | Content-Language | |
|---|---|---|---|
| What it says | “This text is in this language” | “Here are the other language or region versions of this page” | “This document is meant for this audience language” |
| Where it lives | On <html> or any element | <link> in the head, HTTP header or XML sitemap | HTTP response header (the meta version is discouraged) |
| Code format | BCP 47 (e.g. zh-Hans, en-GB) | ISO 639-1 language, optional ISO 3166-1 Alpha 2 region | Language tags |
| Used by Google Search? | No | Yes, to show the right version | Not documented by Google |
| Used by other tools? | Screen readers, browsers, translation and spelling tools | Mainly search engines | Older Bing guidance lists it |
hreflang is the tag that matters for Google when you have several versions of the same page. Google’s localized versions guide explains that each version must list itself and all others, and that “If two pages don’t both point to each other, the tags will be ignored.” It also notes that Google doesn’t use hreflang or lang to detect language; hreflang only links the versions together. Our full guide to hreflang tags covers setup.
There is a small trap in the codes. hreflang uses ISO country codes, so the United Kingdom is GB, not UK. Google says codes reserved for something else are ignored. The lang attribute uses BCP 47, which allows script subtags like Hans that hreflang’s simpler format doesn’t mention. Don’t copy values blindly from one to the other.
Content-Language is an HTTP header. The W3C advises that you should never use a meta element with http-equiv="Content-Language" to declare a page’s language, and that an in-page lang declaration overrides the header for the actual text.
What about Bing and other search engines?
Not every search engine works like Google. Bing’s 2011 webmaster post on how to tell Bing your website’s country and language listed the content-language meta tag, the lang attribute on <html> or <title>, the HTTP header, country-code domains and IP lookup as location signals. The same post noted that generic domains like .com don’t influence location:
“Top level domains other than ccTLDs, including .com, .net and .org, do not influence the document location.”
— Bing Webmaster Blog, How To Tell Bing Your Website’s Country and Language
That post is old, so I treat it as a hint, not a current rule. But it is a good reason not to leave lang wrong just because Google ignores it. If you target markets where other search engines matter, see our guide to search engines beyond Google.
Why screen readers and browsers depend on lang
This is the real reason I insist on getting lang right. Software that reads your page aloud needs to know which pronunciation rules to use.
The accessibility standard WCAG makes it a Level A requirement, the most basic level. Success Criterion 3.1.1, Language of Page, says the default human language of each page must be programmatically determined. In plain words: software must be able to tell the page’s language from the code. The W3C explains the benefit simply: “As a result, users with disabilities will be better able to understand the content.”
Imagine a blind visitor using a screen reader on a Spanish page marked lang="en". The screen reader reads Spanish words with English pronunciation rules. It sounds like nonsense. The visitor leaves.
There is also a Level AA rule, 3.1.2 Language of Parts, for phrases in a different language inside a page. The W3C strongly encourages it even for sites aiming at Level A.
Browsers use lang for other things too:
- Hyphenation. MDN’s page on CSS
hyphensexplains that browsers only hyphenate when the language is declared and a matching dictionary is available. - Fonts and characters. For Chinese, Japanese and Korean, the declared language can affect which version of a character the browser draws.
- Translation and spelling tools often use it as a starting point, which is why a wrong value can trigger a “Translate this page?” prompt for a page that is already in the reader’s language.
For more on how accessibility work overlaps with search, see our guide to accessibility and SEO.
Pages that mix languages
Real pages are rarely in one pure language. A Hindi recipe blog uses English brand names. A Canadian store shows English and French side by side on the homepage. A law firm quotes a Latin phrase. Here is how I handle each case.
| Situation | What to do |
|---|---|
| One main language with a few foreign words or brand names | Set lang on <html> to the main language. Mark longer foreign phrases with their own lang. Brand names and common loanwords don’t need marking. |
| A quote or passage in another language | Wrap it in an element with its own lang, for example <blockquote lang="fr">. |
| A language switcher that lists “Español”, “Deutsch”, “Français” | Add lang to each link so a screen reader pronounces each name correctly. |
| A bilingual page with equal amounts of two languages | Pick the language of the main content for <html>, and mark the other blocks. Better still, split into two pages linked with hreflang, as Google advises. |
| User reviews in many languages | If your system knows the review language, add lang to each review. If not, leave the page default. |
One limit worth knowing: the W3C notes that the HTML title attribute can’t contain markup, so you can’t mark a language change inside it. If you use tooltip text, keep it in the page’s main language. I discuss the title attribute more in the title attribute and SEO.
Right-to-left languages need one more thing. lang doesn’t set text direction. For Arabic, Hebrew or Urdu, you also need the dir="rtl" attribute, as the W3C points out.
Finding and fixing wrong lang values across a site
Wrong lang values are common, especially on sites that were translated after launch. Here is a step-by-step process I would follow.
- Crawl the site. Use a crawler with custom extraction (our Screaming Frog guide shows how) to pull the
langvalue from the<html>tag of every page. - Group pages by folder or domain. For example, all
/es/pages should share one value, all/de/pages another. - Compare with the real content language. Spot-check a few pages in each group by reading them, or use a language detection script on the main text.
- Find the source of the value. In WordPress, the
langattribute normally comes from the Site Language under Settings → General, or from your translation plugin for each language version. On other platforms it usually comes from the store or site locale setting. - Fix it at template level. Change the setting or the theme file, not individual pages.
- Check that hreflang matches. Make sure each page’s hreflang self-reference describes the same language as its
langvalue, with the correct code format for each. - Re-crawl and test with a screen reader. Turn on VoiceOver (Apple) or TalkBack (Android) and listen to a few pages in each language.
An example audit of a three-language store (hypothetical)
This is an example to show the method, not real data. Imagine a store with 400 English pages, 400 Spanish pages under /es/ and 400 French pages under /fr/. A crawl finds:
- All 400 English pages:
lang="en-US". Correct. - All 400 Spanish pages:
lang="en-US". Wrong. The translation plugin wasn’t set to change the attribute. - 380 French pages:
lang="fr-FR". 20 French blog posts, built with a separate landing page tool: nolangat all.
So 420 of 1,200 pages (35%) have a missing or wrong value. Google would still read the Spanish and French text correctly. But every screen reader user on those 420 pages gets the wrong pronunciation, Bing gets a mixed signal, and browsers may offer to translate Spanish pages that are already in Spanish. The fix is one plugin setting and one template change.
Common wrong values and what they cause
Here is a quick reference for the errors I see most.
| Wrong value | Problem | Fix |
|---|---|---|
No lang attribute | Language unknown to assistive tech; fails WCAG 3.1.1 | Add it to <html> in the template |
lang="" | Language set to unknown | Set a real code |
lang="en" on every language version | Wrong pronunciation and translation prompts | Set per language in your plugin or locale settings |
lang="uk" meaning United Kingdom | uk is the code for Ukrainian | Use en-GB |
lang="english" | Not a valid code | Use en |
lang="en_US" with an underscore | Invalid format; tags use hyphens | Use en-US |
Questions people ask about the lang attribute and SEO
Does the lang attribute help my rankings in Google?
No. Google says it uses the visible text to detect language and ignores lang. It still matters for accessibility and possibly other search engines.
Can I use lang instead of hreflang?
No. They do different jobs. lang describes the text on one page. hreflang tells Google which pages are translations or regional versions of each other.
Should I use en or en-US?
Either is valid. Use the region only if it is true and useful, for example en-GB on a page with British spelling and prices in pounds.
Do I need the Content-Language meta tag?
No. The W3C advises against using it to declare language. Use lang on the <html> tag instead.
Will a wrong lang value stop my page being indexed?
No. Google will still index it and detect the language from the text. The harm is to users of assistive technology and to tools that trust the attribute.
Getting your language declarations right this month
Here is the short version. Set lang correctly on every page’s <html> tag, mark longer passages in other languages, and use hreflang to connect your language versions for Google. Don’t expect lang to move rankings in Google; do expect it to make your site work properly for screen readers, browsers and other search engines.
If you are expanding into new countries or languages, our international SEO guide and content localization guide are good next reads. And if you want us to audit your language setup, hreflang and translated templates, our SEO team can help. Request a free quote and tell us which markets you serve.
Further reading on html lang attribute
- Iframes and Embedded Content: What Google Indexes
- Click Depth: How Far Your Pages Sit from the Homepage
- Does Bold Text Help SEO? Formatting for Skimmers
Sources for this HTML lang attribute guide
- Google Search Central: Managing multi-regional and multilingual sites
- Google Search Central: Tell Google about localized versions of your page
- Google Search Central: Meta tags and attributes that Google supports
- W3C Internationalization: Declaring language in HTML
- W3C: Understanding SC 3.1.1 Language of Page
- MDN Web Docs: lang global attribute
- MDN Web Docs: hyphens
- Bing Webmaster Blog: How To Tell Bing Your Website’s Country and Language (2011)




