Language Attribute

No Comments
Language attribute

What the language attribute is

The language attribute is the lang attribute you put on the HTML tag - <html lang="en"> - to declare what natural language the page's content is written in. It is small, easy to forget, and it quietly drives screen-reader pronunciation, browser translation prompts, and correct rendering of language-specific typography.

Get it wrong and a screen reader will read your English page in a French accent, browsers may offer to "translate" a page that is already in the user's language, and assistive tech guesses instead of knowing. It is one line of markup with an outsized accessibility impact.

lang is not hreflang - clear this up first

These two get conflated constantly, and they do completely different jobs. Confusing them leads people to think one line of lang handles their international SEO. It does not.

lang attributehreflang
Answers"What language is this page?""Where are the other language/region versions?"
AudienceBrowsers, screen readers, assistive techSearch engines
Lives onThe <html> tag of the pageHTML head, HTTP header, or XML sitemap
ScopeThis one page onlyA cluster of alternate pages that reference each other
Primary benefitAccessibility and correct renderingServing the right localized page in search

Short version: lang describes the current page for the browser; hreflang maps the page to its siblings for search engines. A properly built multilingual site uses both - lang on every page, hreflang to connect the localized versions. One never substitutes for the other.

How to write it correctly

The value is a BCP 47 language tag: an ISO 639-1 language subtag, optionally followed by a region subtag. Language is required; region is optional and only worth adding when it changes meaning (spelling, currency, date format).

<!-- Generic French, any region -->
<html lang="fr">

<!-- Canadian French specifically -->
<html lang="fr-CA">

<!-- British English -->
<html lang="en-GB">

You can also mark a single element that switches language mid-page, which is exactly what assistive tech needs to pronounce a quote correctly:

<p>She ended every email with
  <span lang="fr">bon courage</span>.</p>

That lang="fr" on the span tells a screen reader to pronounce those two words in French while reading the rest in English. Without it, the reader plows through "bon courage" with English pronunciation rules and it comes out as gibberish - a small detail that makes a real difference to anyone relying on audio to read your page.

How to check it on your own site

  1. View source on a page and confirm the opening <html> tag has a lang attribute with a real value - not empty, not a placeholder.
  2. Confirm the value actually matches the page's content language. A template that hard-codes lang="en" on translated pages is a classic bug.
  3. Validate the tag format - en, fr-CA, pt-BR are valid; made-up strings like english or en_US (underscore) are not.
  4. Run the page through an accessibility checker (browser Lighthouse or axe) - a missing or invalid lang is a standard flagged failure.
  5. For multilingual sites, check that each locale template outputs its own correct lang, and spot-check any mid-page lang spans on quoted foreign text.
  6. Crawl the site and pull the lang value per URL so you can catch whole sections stuck on the wrong language in bulk.

Common mistakes and how to fix them

  • Missing the attribute entirely. Plenty of themes ship <html> with no lang. Add it in the template so every page inherits the right value.
  • Same lang on every translated page. A CMS hard-codes lang="en" and your Spanish and German pages all claim to be English. Wire the value to the page's actual content language.
  • Using an underscore or a full word. lang="en_US" and lang="English" are both invalid. Use hyphenated BCP 47 tags like en-US.
  • Over-specifying the region. lang="en-US" on content that is just plain English adds nothing and can be wrong for other English readers. Use bare en unless the region genuinely matters.
  • Assuming lang handles international SEO. It does not tell Google which version to rank where - that is hreflang's job. Set both; do not lean on lang alone.

FAQ

Does the lang attribute affect rankings?

Not as a direct ranking factor. Its value is accessibility and correct browser behavior, and it helps Google understand the page's language as a supporting signal. The heavy lifting for international targeting is done by hreflang, not lang.

Do I need lang if I already have hreflang?

Yes. They serve different audiences - lang for browsers and assistive tech, hreflang for search engines. Having hreflang does not excuse a missing or wrong lang, and vice versa. Set both.

What is the difference between the lang attribute and the content-language meta tag?

The lang attribute on <html> is the modern, preferred way to declare page language and is what assistive tech reads. The old <meta http-equiv="content-language"> tag is legacy and largely ignored - use the lang attribute instead.

Should I set a region like en-US or just en?

Use bare en unless the region changes the content in a way that matters - spelling, currency, date formats. Adding a region you do not actually need just risks mismatching part of your audience.

Can I change language partway down a page?

Yes - put lang on the specific element, like a <span lang="fr"> around a French phrase inside an English paragraph. Screen readers switch pronunciation for that element, which is the whole point of the attribute at the element level.

Related reading

Claude Vincent is a technical SEO consultant focused on crawlability, rendering, and AI-search visibility. He writes the field guides and case studies at SEO ProCheck, with a bias toward the durable, unglamorous work that decides whether search engines and AI answer engines can actually read and cite a site.

About SEO ProCheck

Technical SEO consulting and GEO strategy with 20 years of enterprise experience. Case studies, resources, and tools for search and AI visibility.

Work With Me

Technical SEO audits, GEO strategy, site migrations, and international SEO. Hourly consulting for teams who need hands-on support, not just reports.

Subscribe to our newsletter!

More from our blog