Html has lang

Quick win

Found on 17% of audited stores.

Add a valid `lang` attribute to the `<html>` element so browsers, screen readers, and search engines know what language your page is written in.

What it is

Every HTML page should declare its primary language in the opening `<html>` tag using a `lang` attribute — for example, `<html lang="en">` for English. This single attribute tells browsers, screen readers, and search-engine crawlers what human language the page content is written in. WCAG Success Criterion 3.1.1 ("Language of Page") requires it. A common mistake is using the XML version (`xml:lang`) instead of the standard HTML `lang` attribute — only `lang` is valid in HTML documents.

Why it matters

Screen readers use the `lang` attribute to select the correct pronunciation engine and voice profile; without it, a visually-impaired customer may hear your entire site read aloud in the wrong language, making it effectively unusable. This is a Level A WCAG violation — the lowest bar for accessibility compliance — and is frequently cited in accessibility audits and legal complaints under the ADA, the European Accessibility Act, and equivalent laws worldwide, exposing you to real legal and financial risk. Search engines also use the declared language to serve your pages to the right audiences, so a missing or wrong `lang` value can quietly undermine your international SEO. Fixing it takes less than five minutes and has zero negative side effects.

How to fix it

  1. Identify the opening `<html>` tag in your site's main layout or theme file (sometimes called a template, master page, or head file).
  2. Check whether the tag already has `xml:lang` — if so, replace it with `lang` (e.g., change `<html xml:lang="en">` to `<html lang="en">`).
  3. If there is no language attribute at all, add `lang="xx"` where `xx` is the correct BCP 47 language code for your content (e.g., `en` for English, `en-US` for American English, `fr` for French, `de` for German, `es` for Spanish, `ja` for Japanese).
  4. Save and publish the change, then load any page of your site and use your browser's 'View Page Source' to confirm the `<html>` tag now reads `<html lang="en">` (or your chosen code).
  5. If your store serves multiple languages, ensure each language-specific page or template declares the correct `lang` value for that language — not just the default.
  6. Re-run your accessibility scanner or browser extension (e.g., axe DevTools) to confirm the html-has-lang violation is resolved.

Fix it on your platform

Pick your platform for the exact steps.

How to fix html has lang on Shopify
  1. In your Shopify admin, go to Online Store → Themes.
  2. Next to your active theme, click Actions → Edit code.
  3. In the left file list, under Layout, click theme.liquid (this is your site's master template).
  4. Find the opening `<html` tag near the top of the file.
  5. If it already contains `xml:lang`, replace it with `lang`. If neither exists, add `lang="{{ shop.locale }}"` — Shopify's Liquid variable that outputs the store's active locale code automatically.
  6. The result should look like: `<html lang="{{ shop.locale }}">` (or a hard-coded code like `lang="en"` if you only serve one language).
  7. Click Save. Verify by viewing your storefront source.
How to fix html has lang on Shopify Plus
  1. Same as Shopify: Online Store → Themes → Actions → Edit code → Layout/theme.liquid.
  2. Update the `<html>` tag to include `lang="{{ shop.locale }}"` so it works across all expansion stores and locale-specific storefronts automatically.
  3. For headless storefronts built on the Storefront API, add the `lang` attribute in your framework's root HTML document component (e.g., `_document.js` in Next.js).
  4. Click Save and verify via View Source.
How to fix html has lang on WooCommerce
  1. The `lang` attribute in WordPress is typically output by the `language_attributes()` template tag in your theme's header.
  2. In your WordPress admin, go to Appearance → Theme File Editor (or use an FTP/SFTP client).
  3. Open your active theme's header.php file.
  4. Find the `<html` tag. It should call `<html <?php language_attributes(); ?>>` — this is the correct WordPress way and automatically outputs the correct `lang` attribute based on Settings → General → Site Language.
  5. If the tag instead has a hard-coded `xml:lang` or is missing the language altogether, replace it with `<html <?php language_attributes(); ?>>`.
  6. Go to Settings → General and confirm the 'Site Language' is set to your primary language.
  7. Save and verify via View Source. If using a page-builder theme (Elementor, Divi, etc.) that overrides header.php, check that theme's specific header template or use a plugin like 'Head, Footer and Post Injections' as a last resort.
How to fix html has lang on BigCommerce
  1. In your BigCommerce admin, go to Storefront → My Themes.
  2. Click Customize on your active theme, then in the Theme Editor click Advanced → Edit Theme Files (or download the theme, edit locally, and re-upload).
  3. Open templates/layout/base.html (the path may vary slightly by theme — look for the file containing the `<html>` tag).
  4. Add or correct the `lang` attribute: `<html lang="en">` (replace `en` with your store's primary language code).
  5. Save and upload, then verify via View Source on your storefront.
How to fix html has lang on Wix
  1. In Wix, the `lang` attribute on the `<html>` element is controlled by your site's language setting, not by hand-editing HTML.
  2. Go to your Wix Dashboard → Settings → Multilingual (or Language & Region).
  3. Set your primary site language. Wix will automatically inject the correct `lang` attribute into the HTML for that language.
  4. If you use Wix Multilingual, each language version of your site gets its own `lang` tag automatically.
  5. After saving, use View Source on your live site to confirm `<html lang="en">` (or your language) is present.
  6. Note: Wix does not allow direct editing of the `<html>` tag — the language setting is the only control point.
How to fix html has lang on Wix Studio
  1. In Wix Studio, navigate to the site's Settings panel and set the primary language under Language & Region.
  2. Wix Studio injects the `lang` attribute automatically based on this setting.
  3. For multilingual sites, use the built-in Multilingual tool to ensure each locale gets the correct `lang` value.
  4. Verify with View Source after publishing.
How to fix html has lang on Squarespace
  1. Squarespace automatically sets the `lang` attribute based on your region/language settings.
  2. Go to Settings → Region & Language and ensure the correct language is selected.
  3. Squarespace will inject `<html lang="xx">` accordingly on all pages.
  4. If you need to override this (e.g., for a specific language not in the list), go to Settings → Advanced → Code Injection and add a small JavaScript snippet: `document.documentElement.lang = 'fr';` (replace `fr` with your code) — this is a workaround only.
  5. Verify with View Source after saving.
How to fix html has lang on Webflow
  1. In the Webflow Designer, open your Project Settings (the gear icon in the top-left).
  2. Go to the Publishing tab (or General tab depending on your Webflow version).
  3. Find the 'Locale' or 'Language' field and set your primary language — Webflow uses this to set the `lang` attribute on the `<html>` tag.
  4. For Webflow Localization (multi-language), each locale automatically gets its correct `lang` attribute.
  5. Publish your site and verify via View Source.
How to fix html has lang on Adobe Commerce (Magento)
  1. In your Magento admin, go to Content → Design → Configuration.
  2. Select the store view you want to update and click Edit.
  3. Under the HTML Head section, check for any overrides, but the primary control is the locale set in Stores → Configuration → General → General → Locale Options → Locale.
  4. The `lang` attribute is output in your theme's root template. Navigate to your theme directory (e.g., app/design/frontend/Vendor/theme/Magento_Theme/templates/root.phtml) and verify the `<html>` tag uses `<?php /* @escapeNotVerified */ echo $htmlAttributes ?>` or directly includes the lang attribute.
  5. If the tag is missing `lang`, add it: `<html lang="<?= $block->escapeHtmlAttr($currentLocale) ?>">` — you may need to pass the locale from your layout XML or block class.
  6. Clear the Magento cache (System → Cache Management → Flush Magento Cache) and verify via View Source.
How to fix html has lang on Magento Open Source
  1. Follow the same steps as Adobe Commerce (Magento) above.
  2. The root template is located at app/design/frontend/[Vendor]/[theme]/Magento_Theme/templates/root.phtml.
  3. Set the locale in Stores → Configuration → General → General → Locale Options.
  4. Flush cache after saving changes.
How to fix html has lang on PrestaShop
  1. In your PrestaShop admin, go to International → Translations → Languages to confirm your default language is set correctly.
  2. Open your active theme's layout file — typically themes/[your-theme]/templates/layouts/layout-full-width.tpl or layout-both-columns.tpl.
  3. Find the `<html>` tag and ensure it reads `<html lang="{$language.iso_code}">` — PrestaShop provides the `{$language.iso_code}` Smarty variable for this.
  4. Save and verify via View Source.
How to fix html has lang on OpenCart
  1. In your OpenCart admin, go to System → Settings → Store and ensure the Language is correctly set.
  2. Open your active theme's main template file, typically catalog/view/theme/[your-theme]/template/common/header.twig.
  3. Find the `<html>` tag and update it to: `<html lang="{{ lang }}">` (OpenCart passes a lang variable to templates).
  4. Save and verify via View Source.
How to fix html has lang on Ghost
  1. In your Ghost admin, go to Settings → General and set the Publication Language to the correct BCP 47 code (e.g., `en`).
  2. Ghost automatically injects `<html lang="{{@site.locale}}">` in the default Casper theme and most modern themes.
  3. If your custom theme is missing it, edit your theme's default.hbs file and update the `<html>` tag to `<html lang="{{@site.locale}}">`, then re-upload the theme ZIP.
  4. Verify via View Source after saving.
How to fix html has lang on Next.js
  1. Open pages/_document.js (Pages Router) or app/layout.js (App Router).
  2. For Pages Router: In your `<Html>` component, add the lang prop: `<Html lang="en">`.
  3. For App Router: In your root layout.js, set the lang attribute on the html element: `export default function RootLayout({ children }) { return <html lang="en">{children}</html>; }`
  4. For i18n sites using next.config.js internationalization, you can use the locale from the router: `const { locale } = useRouter();` and pass it as the lang value.
  5. Deploy and verify via View Source.
How to fix html has lang on Headless / Custom (I build in code)
  1. Locate the file that renders the root HTML document — typically index.html, _document.js, app.html, layout.html, or your framework's equivalent.
  2. Find the `<html>` tag and add a `lang` attribute with the correct BCP 47 language code, e.g., `<html lang="en">`.
  3. If you serve multiple languages, set the lang attribute dynamically based on the current locale/route.
  4. Remove any `xml:lang` attribute if present (it is not valid in HTML5).
  5. Deploy and verify via View Source or browser DevTools.

Does your site have this issue?

Run a free SEOLZ scan to find html has lang — and every other issue — across your whole site in minutes.

Scan my site free

Frequently asked questions

What is Html has lang?

Every HTML page should declare its primary language in the opening `<html>` tag using a `lang` attribute — for example, `<html lang="en">` for English. This single attribute tells browsers, screen readers, and search-engine crawlers what human language the page content is written in. WCAG Success Criterion 3.1.1 ("Language of Page") requires it. A common mistake is using the XML version (`xml:lang`) instead of the standard HTML `lang` attribute — only `lang` is valid in HTML documents.

Why does html has lang matter?

Screen readers use the `lang` attribute to select the correct pronunciation engine and voice profile; without it, a visually-impaired customer may hear your entire site read aloud in the wrong language, making it effectively unusable. This is a Level A WCAG violation — the lowest bar for accessibility compliance — and is frequently cited in accessibility audits and legal complaints under the ADA, the European Accessibility Act, and equivalent laws worldwide, exposing you to real legal and financial risk. Search engines also use the declared language to serve your pages to the right audiences, so a missing or wrong `lang` value can quietly undermine your international SEO. Fixing it takes less than five minutes and has zero negative side effects.

How do I fix html has lang?

Add a valid `lang` attribute to the `<html>` element so browsers, screen readers, and search engines know what language your page is written in.

Authoritative references

Related Accessibility (WCAG) issues