# Check the lang attribute

- Check 10.19 · On-page SEO and metadata · Important
- Source: https://checklist-seo-geo.com/en/page-seo-metadata/check-lang-attribute
- Check that the lang attribute of the html tag declares the right language on every page, and fix it on WordPress, Shopify, Laravel, Next.js or Nuxt.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/page-seo-metadata/check-lang-attribute.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The `lang` attribute of the `<html>` tag declares the main language of the page: `<html lang="fr">` for a page in French. The check consists of making sure it is present, valid and correct on every template, then fixing it where it is set: the CMS language setting, the theme template or the application configuration. The multilingual case, where the value changes from one page to another, is covered in [set html lang on each page](https://checklist-seo-geo.com/en/development-accessibility-language/set-html-lang-each-page).

## Why it matters

**Accessibility first.** Screen readers choose their voice and pronunciation rules based on the declared language. A French page marked `lang="en"` is read with an English accent, often unintelligibly. WCAG (Web Content Accessibility Guidelines) success criterion 3.1.1, level A, requires that the default language of each page can be programmatically determined, which is what the `lang` attribute does.

**Text rendering.** The browser uses it for automatic hyphenation (`hyphens: auto` in CSS), glyph selection in some fonts, quotation marks generated by CSS, and to decide whether to offer to translate the page.

**Google does not use it to detect the language.** Its documentation is explicit: it determines the language of a page from its visible content and does not use language information in the code, such as the `lang` attribute. So do not count on this attribute to target a language in Google: that is the job of the content, of [hreflang](https://checklist-seo-geo.com/en/hreflang-regional-variants/implement-hreflang-equivalent-pages) and of separate URLs for each language. Bing documents the language signals it uses less precisely; a correct attribute costs nothing and removes any ambiguity.

**What breaks when it is wrong.** The most common case is not a missing attribute but a wrong one: a French site installed with the software’s default language (`en-US`), or a Laravel application left on `APP_LOCALE=en`. Accessibility audits flag it, screen readers mispronounce, and tools that rely on the code (translation, content extraction) start from wrong information.

## What it improves

- **Accessibility**: correct pronunciation by screen readers and speech synthesis; compliance with WCAG criterion 3.1.1.
- **Rendering**: consistent hyphenation, typography and translation prompts.
- **Lighthouse audit**: the accessibility checks on the presence and validity of `lang` pass.
- **Generative engines and third-party tools**: language metadata consistent with the content. How they use the attribute is not documented.
- **Google rankings**: no effect; Google ignores the attribute when determining the language.

## How to check

Read the `<html>` tag served:

```bash
curl -s https://example.com/ | grep -o -i -m 1 '<html[^>]*>'
```

Expected result: `<html lang="fr">` or `<html lang="fr-FR">`. Repeat on one example of each template (home, article, category, product, 404 page): a template written separately may have its own tag.

Values to recognize:

| Value | Verdict |
|---|---|
| `fr`, `fr-FR`, `fr-CA`, `fr-BE` | Correct (BCP 47 language tag) |
| `en`, `en-US` on a page in French | Wrong: installation language never changed |
| `fr_FR` | Invalid: BCP 47 uses a hyphen, not an underscore (the underscore is the `og:locale` format) |
| `french`, reversed `FR-fr`, `fra-FR` | Invalid or non-standard |
| `lang=""` | Declared language unknown |
| Attribute missing | Language unknown to assistive technologies |

For a site-wide check:

- **Lighthouse**, Accessibility category: it checks that `<html>` has a `lang` attribute and that its value is valid.
- The W3C **Internationalization Checker**: it shows the language declared by the attribute, by the `Content-Language` HTTP header and by any meta tag, and flags inconsistencies.
- **Screaming Frog**: custom extraction with the XPath `/html/@lang` across the whole crawl, then sort the column to spot isolated values.

## How to implement

### Before you start

**Choose the value.** For a French-language site meant for all French speakers, `fr` is enough. Add the region (`fr-CA`, `fr-BE`, `fr-CH`) only if the content is genuinely adapted to that country. The region in `lang` describes the language variant, not the targeted country. See [distinguish language from geotargeting](https://checklist-seo-geo.com/en/international-architecture/distinguish-language-from-geotargeting).

**Where to put it.** On the `<html>` tag only, once. For a passage in another language (a quotation, a book title), add `lang` to the element concerned: `<blockquote lang="en">`. This is WCAG criterion 3.1.2, level AA. See [mark passages in another language](https://checklist-seo-geo.com/en/development-accessibility-language/mark-passages-another-language).

**What not to use instead.** The W3C advises against `<meta http-equiv="Content-Language">` for declaring the language of a page. The `Content-Language` HTTP header can indicate the intended audience, but `lang` in the HTML is what counts for the language of the text.

### WordPress

Versions: WordPress 6.4 to 7.1.

WordPress writes the attribute from the site language, through the `language_attributes()` function called in the theme header.

1. `Settings > General`, “Site Language” field: choose “Français”. Save. The tag becomes `<html lang="fr-FR">`.
2. If the value is still wrong, open the theme’s (or child theme’s) `header.php` and check the tag:

```php
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
```

A hard-coded value (`<html lang="en-US">`) in a purchased theme is a theme bug: fix it in a child theme. Block themes handle the tag automatically.

3. A user can display the admin in another language (`Profile > Language`): this does not change the language of the public site.

With Polylang or WPML, the attribute follows the language of each page; check one page per language.

### Shopify

Versions: Shopify admin, all plans, Horizon and Dawn themes, November 2026.

Recent themes write the active language, as Horizon and Dawn do in `layout/theme.liquid`:

```liquid
<html class="js" lang="{{ request.locale.iso_code }}">
```

The store’s default language is set in `Settings > Languages`. If your theme writes a fixed value, replace it with `{{ request.locale.iso_code }}` in `layout/theme.liquid` (`Online Store > Themes > … > Edit code`), and do the same in `layout/password.liquid` and any other layout file.

### PrestaShop

Versions: PrestaShop 8 and 9, Classic and Hummingbird themes.

The Classic theme writes the attribute from the language of the store being displayed. Check the default language in `International > Localization` (Configuration), then the code of each language in the `Languages` tab of the same section (ISO code and language code fields). A third-party theme that writes a fixed value is fixed in `templates/layouts/layout-both-columns.tpl` or its equivalent, using the language variable provided by the Classic theme.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.x.

The language comes from the store view locale: `Stores > Settings > Configuration > General > General > Locale Options`, “Locale” field, at store view level (`French (France)`). The Luma theme then writes `<html lang="fr">`. Flush the cache (`System > Cache Management`) and check.

### Drupal

Versions: Drupal 10 and 11.

Drupal writes the language of the current page in the theme’s `<html>` tag (`html.html.twig`). The default language is set in `Configuration > Regional and language > Languages` (`/admin/config/regional/language`), with the Language module enabled. If the site was installed in English, add French and set it as the default.

### Wix, Squarespace and Webflow

Versions: Wix Editor and Wix Studio, Squarespace 7.1, Webflow, all plans, November 2026.

The declared language comes from the site language setting in the settings (main language, or language and region). If the published source code shows `lang="en"` on a French site, change this setting, republish, then check again with the command from the “How to check” section.

### Laravel

Versions: Laravel 10 to 13.

The default template writes the application locale:

```blade
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
```

The `str_replace` converts `fr_FR` to `fr-FR`. The locale comes from `config/app.php`, `locale` key; only the place where you set it changes with the version. After setting it, check every layout template (`resources/views/layouts/`, error pages in `resources/views/errors/`), and emails if you publish their web version.

#### Laravel 11 to 13

The `locale` key is fed by an environment variable. In `.env`:

```ini
APP_LOCALE=fr
APP_FALLBACK_LOCALE=fr
```

Then `php artisan config:clear`, or `php artisan config:cache` in production.

#### Laravel 10

The value is hard-coded in `config/app.php`:

```php
'locale' => 'fr',

'fallback_locale' => 'fr',
```

Then `php artisan config:clear`, or `php artisan config:cache` in production.

### Symfony

Versions: Symfony 6.4, 7.4 and 8.x.

In `templates/base.html.twig`:

```twig
<!DOCTYPE html>
<html lang="{{ app.request.locale|replace({'_': '-'}) }}">
```

The default locale is set in `config/packages/translation.yaml`, key `framework.default_locale: fr`.

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

#### App Router

The attribute goes in the root layout:

```tsx
// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="fr">
      <body>{children}</body>
    </html>
  )
}
```

For a multilingual site with a `[lang]` segment, put the root layout in `app/[lang]/layout.tsx` and write `<html lang={lang}>` from the route parameters, which Next.js 15 and 16 pass as a promise (`const { lang } = await params`).

#### Pages Router

With i18n routing (`i18n.locales` and `i18n.defaultLocale` in `next.config.js`), Next.js itself writes the route’s language on `<html>`. Without i18n routing, set the attribute in `pages/_document.tsx`:

```tsx
import { Html, Head, Main, NextScript } from 'next/document'

export default function Document() {
  return (
    <Html lang="fr">
      <Head />
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}
```

### Nuxt

Versions: Nuxt 3 and 4; `@nuxtjs/i18n` module 9 and 10.

In `nuxt.config.ts`:

```ts
export default defineNuxtConfig({
  app: {
    head: {
      htmlAttrs: {
        lang: 'fr',
      },
    },
  },
})
```

With the `@nuxtjs/i18n` module, call `useHead(useLocaleHead())` in `app/app.vue` (Nuxt 4) or `app.vue` (Nuxt 3): the `lang` option, enabled by default, makes the attribute follow the route’s language.

### Astro

Versions: Astro 5 to 7.

In the layout template, for example `src/layouts/Base.astro`: `<html lang="fr">`. With Astro’s i18n routing, use `Astro.currentLocale`: `<html lang={Astro.currentLocale}>`.

## Common mistakes

- **Installation language kept**: `lang="en-US"` on a French site, because WordPress, Drupal or Laravel was installed in English.
- **Underscore**: `lang="fr_FR"`, copied from a system locale or `og:locale`. BCP 47 uses a hyphen.
- **Forgotten templates**: the 404 page, the maintenance page, AMP pages or separately built landing pages keep the old value.
- **A fixed language on a multilingual site**: every version declares `fr`. See [set html lang on each page](https://checklist-seo-geo.com/en/development-accessibility-language/set-html-lang-each-page).
- **Believing that `lang` targets a language in Google**: Google detects the language from the visible content. Targeting relies on content, separate URLs and hreflang.
- **Region added out of habit**: `fr-FR` is not wrong, but `fr-CA` on content written for France is.
- **A `Content-Language` meta tag instead of the attribute**: discouraged by the W3C.

## Frequently asked questions

### Does Google use the lang attribute for SEO?

No. Google states that it determines the language of a page from its visible content and does not use language information in the code, such as the lang attribute or the URL. Filling in lang therefore targets no language in Google. The attribute is still needed for accessibility, text rendering by the browser and consistent metadata; language targeting relies on content, separate URLs and hreflang.

### Should I write lang="fr" or lang="fr-FR"?

Both are valid. Use fr for content in standard French meant for all French speakers, and a regional variant such as fr-CA or fr-BE only if the text is genuinely adapted to that country, through its vocabulary, prices or practical information. WordPress writes fr-FR by default when the site language is French: this is not an error to fix.

### Does the lang attribute replace hreflang?

No, they do not play the same role. The lang attribute describes the language of the page text for the browser and assistive technologies. Hreflang, placed in the HTML, the HTTP headers or the sitemap, tells search engines which other URLs offer the same content in other languages or for other countries. A multilingual site needs both, with values that are consistent with each other.

### How do I declare an English quotation in a French page?

Add the lang attribute to the element that contains the passage: for example lang="en" on the blockquote tag, or on a span for a short phrase. Screen readers then switch pronunciation for that passage alone, then return to French. This is the requirement of WCAG criterion 3.1.2, level AA. There is no need to do it for borrowed words that have passed into common usage, such as “week-end”.

## Resources

- [Google Search Central: Managing multi-regional and multilingual sites](https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites?hl=en)
- [MDN: lang attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang)
- [W3C: Declaring language in HTML](https://www.w3.org/International/questions/qa-html-language-declarations)
- [W3C: Choosing a language tag](https://www.w3.org/International/questions/qa-choosing-language-tags)
- [W3C: Understanding Success Criterion 3.1.1 Language of Page](https://www.w3.org/WAI/WCAG22/Understanding/language-of-page.html)
- [W3C: Internationalization Checker](https://validator.w3.org/i18n-checker/)
- [WordPress: language_attributes()](https://developer.wordpress.org/reference/functions/language_attributes/)

Next steps: [set html lang on each page](https://checklist-seo-geo.com/en/development-accessibility-language/set-html-lang-each-page) and [set up a favicon](https://checklist-seo-geo.com/en/page-seo-metadata/set-up-favicon).
