Skip to content
FunnelGuard

Fix guide by FunnelsGuard

HTML lang attribute missing or wrong: how to find and fix it

SEO-274Low impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

The lang attribute sits on the opening <html> tag. It holds a language code such as en, de or pt-BR. The code follows the BCP 47 standard: a language, with an optional region after a hyphen.

The problem comes in three forms: the attribute is missing, the value is invalid (for example lang="english" or en_US with an underscore), or the value is wrong for the page (a French page that says lang="en"). The last one is common when a site is cloned from an English template and then translated.

Correct exampleshtml
<html lang="en">
<html lang="en-GB">
<html lang="de">
<html lang="pt-BR">

Why it costs you leads or sales

The direct impact is low, but it is real. Screen readers use the attribute to choose a pronunciation voice. With the wrong value, a French checkout can be read aloud with English rules, which makes forms and prices hard to follow for blind and low-vision visitors.

Browsers use it too. Chrome can offer to translate a page it thinks is in another language, and a wrong value can trigger that prompt on a page already in the visitor's language. It also affects hyphenation, quote marks and spell checking in form fields. Search engines mostly work out language from the text itself, so treat the attribute as a clean signal rather than a ranking lever.

Where a wrong lang value shows upExample numbers
Where a wrong lang value shows up (example)Screen reader users hear wrong voice: 100 % of affected visitors; Browser translate prompt shown: 40 % of affected visitors; Wrong spellcheck in forms: 30 % of affected visitors038771004030Screen reader users h…Browser translate pro…Wrong spellcheck in f…% of affected visitors

Example: illustrative share of visitors who may notice each side effect on a page with the wrong lang value. Not measured data.

How to check if your site has it

Check a page in under a minute
  1. View the page source

    Open the page, press Ctrl+U (Cmd+Option+U on Mac) and look at the first lines for the <html> tag.

  2. Or use the console

    Open DevTools, go to Console and run document.documentElement.lang. An empty string means the attribute is missing.

  3. Compare to the visible text

    Check the code matches the language the page is actually written in, not the language of your template or your default site setting.

  4. Check each language version

    Repeat on at least one page in every language and region you publish. Also check key funnel pages: checkout, thank-you and booking pages, which often use separate templates.

  5. Run a bulk scan

    Use a crawler such as Screaming Frog (Language tab) or an accessibility tool such as Lighthouse or WAVE, which flag a missing or invalid lang value.

Console checkjavascript
document.documentElement.lang || 'MISSING'

How to fix it

Where you set the value depends on your platform. Use the code that matches the page's language: en, en-GB, en-US and so on. Use a hyphen, never an underscore.

Set the lang attribute by platform
  1. Set the site language

    Go to Settings > General > Site Language and choose the right language. Themes that call language_attributes() in header.php then output the correct lang value.

  2. Check the theme header

    In header.php the tag should read <html <?php language_attributes(); ?>>. If it is hard-coded as lang="en", replace it with that call (use a child theme).

  3. Multilingual plugins

    If you use a translation plugin, make sure each language has its correct locale set in the plugin's language settings so the attribute changes per page.

Correct opening tag for a German pagehtml
<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <title>Kontakt</title>
</head>

How to confirm it's fixed

Confirmation checks
  • document.documentElement.lang returns the expected code on the live page
  • View source (not just the inspector) shows the lang attribute in the served HTML
  • Each language version shows its own code, with no leftover en on translated pages
  • Codes use hyphens and valid values (en-GB, not en_GB or english)
  • Checkout, thank-you and booking pages are included in your check
  • A Lighthouse accessibility run no longer reports a lang problem

How to prevent it happening again

The attribute usually breaks when a template is copied, a theme is changed, or a new language is added. Build the check into those moments.

Prevention habits
  • Drive the value from the site or page locale, never hard-code it in a shared template
  • After switching themes or page builders, re-check the live source
  • When adding a language, test one page in it before launch
  • Add a lang check to your crawl or accessibility audit and run it after big releases
  • Keep a list of the correct code for each market so translators and developers use the same values

How FunnelGuard handles this

FunnelGuard does not check the html lang attribute yet. It is a possible future check, and nothing in FunnelGuard will tell you today that the value is missing or wrong.

What FunnelGuard does cover is nearby: a robot visitor runs your real customer journeys on a schedule, such as lead forms, checkouts and booking buttons, and checks each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. If a theme change that broke your language setting also breaks a form step or a tag, that is the kind of failure it can report, with a screenshot and a likely cause.

To watch the lang attribute itself, schedule a Screaming Frog crawl or a Lighthouse accessibility run after each release, and spot-check one page per language with document.documentElement.lang. A free plan covers 1 site and 2 journeys with daily checks if you want to monitor the funnel alongside.

Questions people ask

What does the html lang attribute do?

It declares the main language of a web page, for example lang="en" or lang="fr". Screen readers use it to pick the right voice, and browsers use it for translation prompts, spellchecking and hyphenation.

Is the html lang attribute required for SEO?

It is not a major ranking factor, because search engines mostly detect language from the page text. It is still good practice, as it is a clear signal and it is checked in accessibility audits. Hreflang is the signal for linking language versions.

Why is my page language detected wrongly by Chrome?

Chrome looks at the page text and the lang attribute. If your lang value does not match the content, for example lang="en" on a Spanish page, it may offer to translate a page that is already in the visitor's language. Fix the value to match the content.

What is the difference between lang and hreflang?

The lang attribute says what language the current page is in. Hreflang annotations tell search engines which other language or regional versions of the page exist. Multi-language sites should use both.

How do I check the lang attribute of a page?

Open the page, press Ctrl+U to view the source and look at the <html> tag. You can also run document.documentElement.lang in the browser console. An empty result means the attribute is missing.

Should I use en-GB or en-US in the lang attribute?

Use en alone if your content works for all English readers. Use en-GB or en-US if your spelling, currency or wording is specific to that region. Always write the code with a hyphen and capital region letters.

How do I change the html lang attribute in WordPress?

Go to Settings > General and change Site Language. A theme that uses language_attributes() in header.php will then output the new value. If the tag is hard-coded, edit it in a child theme.

Can I set the lang attribute with JavaScript?

You can, but it is better to put it in the served HTML. Crawlers and assistive tools may read the page before scripts run, so a server-rendered value is more reliable.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.