Valid lang
Moderate effortFound on 1% of audited stores.
Add a valid BCP 47 language code to every `lang` attribute on your pages so assistive technologies can read content in the correct language.
What it is
Every HTML page has a `lang` attribute on the `<html>` tag (e.g. `<html lang="en">`) that tells browsers and assistive technologies what language the page is written in. When a page contains a passage in a *different* language, that section should also carry its own `lang` attribute (e.g. `<p lang="fr">`). The value must be a valid BCP 47 language tag — a standardised code like `en`, `en-US`, `fr`, `de`, or `zh-Hans`. An empty, misspelled, or made-up value (such as `lang=""` or `lang="english"`) fails WCAG Success Criterion 3.1.2 (Language of Parts).
Why it matters
Screen readers like JAWS, NVDA, and VoiceOver automatically switch their text-to-speech voice and pronunciation rules based on the `lang` attribute. If the value is missing or invalid, the reader mispronounces words — sometimes so badly that the content becomes completely unintelligible to blind or low-vision shoppers. Beyond accessibility, WCAG 3.1.2 is a Level AA requirement, meaning failing it exposes your store to legal risk under laws such as the ADA in the US, the European Accessibility Act, and equivalent legislation elsewhere. Google also uses language signals to serve your pages to the right audiences, so correct `lang` values support your international SEO.
How to fix it
- Identify every element on your pages that carries a `lang` attribute — start with the root `<html>` tag, then search your templates and content blocks for any inline `lang=` attributes.
- Check each value against the BCP 47 standard: use a two-letter ISO 639-1 language code (e.g. `en`, `fr`, `de`, `ja`) optionally followed by a region subtag separated by a hyphen (e.g. `en-US`, `pt-BR`, `zh-Hant`). Reject any value that is empty, purely numeric, or a full English word like 'english'.
- Replace every invalid value with the correct BCP 47 tag. The page's primary `<html lang="...">` should reflect the dominant language of that page.
- For any content block, widget, or snippet written in a language that differs from the page's primary language, add the correct `lang` attribute directly to the wrapping element (e.g. `<blockquote lang="es">`).
- After saving, validate with a tool such as the axe browser extension or W3C Markup Validator to confirm no `valid-lang` violations remain.
- If your platform auto-generates the `<html>` tag, locate the theme or template file that outputs it and update the variable or hardcoded value there, then re-test across all page templates (home, product, collection, blog, checkout).
<html lang="en">
<!-- For a page in US English -->
<html lang="fr">
<!-- For a page primarily in French -->
<!-- Inline language switch for a passage in Spanish on an English page -->
<p lang="es">Bienvenido a nuestra tienda.</p>
<!-- Region-specific variant -->
<html lang="pt-BR">
<!-- Brazilian Portuguese -->Fix it on your platform
Pick your platform for the exact steps.
How to fix valid lang on Shopify
- In your Shopify admin, go to Online Store → Themes → click 'Customize' on your active theme.
- To edit the root `lang` attribute: from the theme editor click 'Edit code' (or go to Online Store → Themes → Actions → Edit code).
- Open `layout/theme.liquid`. Find the opening `<html` tag — it typically reads `<html class="..." lang="{{ request.locale.iso_code }}">`. Shopify injects the store locale automatically via `request.locale.iso_code`, so ensure the locale itself is correct.
- Verify/update the store locale: Settings → Languages. The 'Published' language's locale code is what Shopify inserts. If that code is wrong, correct it here or switch to a valid language.
- For third-party section snippets or app blocks that hard-code a `lang` attribute, open the relevant `.liquid` file in the code editor and update the value to a valid BCP 47 tag.
- Save changes and re-test with the axe browser extension on your live storefront.
How to fix valid lang on Shopify Plus
- Follow the same steps as Shopify above — `layout/theme.liquid` is the key file.
- For headless or custom storefronts using the Storefront API, ensure the HTML document root rendered by your front-end framework includes `<html lang="[valid-BCP47-code]">`, matching the locale returned by the API.
- If you use Shopify's Translate & Adapt app for multi-language stores, confirm each published locale has a valid ISO code in Settings → Languages.
How to fix valid lang on WooCommerce
- The `lang` attribute on `<html>` is set by WordPress core, not WooCommerce itself — it reads from the site language setting.
- Go to WordPress admin → Settings → General → Site Language. Choose the correct language from the dropdown; WordPress will output the proper BCP 47 code automatically.
- If the `<html>` tag still shows an invalid value, open your active theme's `header.php` (or the root template file in a block theme: `templates/index.html`) and look for a hard-coded `lang=` attribute overriding the WordPress default. Replace it with `<?php language_attributes(); ?>` which outputs the correct value.
- For content in a second language, install the plugin 'Polylang' or 'WPML' and assign the correct language to each post/page — these plugins set `lang` on the `<html>` tag per page automatically.
- Save and verify with the axe browser extension.
How to fix valid lang on BigCommerce
- Go to BigCommerce admin → Storefront → My Themes → click 'Advanced' → 'Edit Theme Files' on your active theme.
- Open `templates/layout/base.html` (Cornerstone theme) and find the `<html` tag.
- BigCommerce injects `lang="{{locale_code}}"` automatically via Handlebars. Check that your store's locale is set correctly: Settings → Store Profile → Default Language.
- If a `lang` attribute is hard-coded to an invalid value in the template, replace it with `{{locale_code}}` to use the dynamic value.
- For any custom HTML widgets containing a `lang` attribute (added via Page Builder), edit the widget in Storefront → Page Builder, open the HTML block, and correct the value.
- Save and preview, then validate with the axe extension.
How to fix valid lang on Wix
- Wix manages the `<html lang>` attribute automatically based on the site language you set in the dashboard — you cannot edit the raw HTML tag directly.
- To set the correct language: Dashboard → Settings → Multilingual (or Settings → Language & Region) → set your Primary Language to the correct language. Wix will output the corresponding valid BCP 47 code.
- For multilingual Wix sites using Wix Multilingual, each language version gets its own `lang` attribute automatically once the language is added and published in Settings → Multilingual → Manage Languages.
- If an invalid `lang` attribute appears inside a custom HTML embed widget (added via Add → Embed → HTML iframe), open that widget and correct the value in the HTML code panel.
- Re-publish the site and verify with the axe browser extension.
How to fix valid lang on Squarespace
- Squarespace automatically sets the `<html lang>` attribute from the site language you configure.
- Go to Settings → Regional → Site Language and select the correct language from the dropdown. Squarespace outputs the corresponding valid BCP 47 code.
- For Code Injection or custom HTML blocks (Pages → Edit → Add Block → Code) that contain a `lang` attribute, open that block and correct the value to a valid BCP 47 tag.
- Squarespace does not expose theme HTML directly, so if the auto-generated `lang` value is still wrong after updating the Regional setting, contact Squarespace Support — it may be a platform bug.
- Publish and verify with the axe extension.
How to fix valid lang on Webflow
- In the Webflow Designer, go to Project Settings (the gear icon) → Localization (or General) and set the primary locale/language. Webflow uses this to populate `<html lang>`.
- Alternatively, open Project Settings → Custom Code → add a `<script>` in Head Code that sets `document.documentElement.lang = 'en';` only if Webflow does not expose a direct language field for your plan — but prefer the Localization setting.
- For Webflow Localization (paid feature): Settings → Localization → add/edit each locale and ensure its language code is a valid BCP 47 tag. Webflow sets `lang` per locale automatically.
- For any Embed components (HTML Embed blocks) in the canvas that contain a `lang` attribute, click the block, open the HTML editor, and correct the value.
- Publish the site and verify with the axe browser extension.
How to fix valid lang on Adobe Commerce (Magento)
- The `<html lang>` tag is rendered in the root page template. In the default Luma/Blank theme, open `vendor/magento/module-theme/view/base/templates/root.phtml` — but do NOT edit core files; instead, copy it to your custom theme: `app/design/frontend/[Vendor]/[theme]/Magento_Theme/templates/root.phtml`.
- In that file, find the `<html` tag. Replace any hard-coded or invalid `lang` attribute with the dynamic value: `lang="<?= $block->escapeHtmlAttr($block->getLocaleCode()) ?>"` or use the store's locale helper to fetch the correct BCP 47 code.
- Set the store locale in Admin → Stores → Configuration → General → General → Locale Options → Locale. Choose the correct locale; Magento maps it to a BCP 47 code.
- For content blocks (CMS Blocks/Pages) that contain inline `lang` attributes in their HTML, edit them in Admin → Content → Blocks (or Pages), switch to HTML view, and correct the `lang` values.
- Run `bin/magento cache:flush` after changes, then verify with the axe extension.
How to fix valid lang on Magento Open Source
- Follow the same steps as Adobe Commerce (Magento) above — the template path and locale configuration are identical in Magento Open Source.
How to fix valid lang on PrestaShop
- PrestaShop generates the `<html lang>` attribute from the active language. Go to Admin → International → Translations → Languages and verify the language code (ISO code field) for each installed language is a valid two-letter ISO 639-1 code (e.g. `en`, `fr`, `de`).
- In your active theme, open `templates/_partials/head.tpl` (or the root layout file). Find the `<html` tag and ensure it uses the Smarty variable `{$language.iso_code}` rather than a hard-coded value.
- If using a custom or third-party theme that hard-codes an invalid `lang` value, override the template in your child theme and correct it.
- Save, clear cache (Admin → Advanced Parameters → Performance → Clear cache), and verify.
How to fix valid lang on WordPress.org
- Same resolution as WooCommerce for the root `lang` attribute: Settings → General → Site Language in the WordPress admin.
- Ensure your active theme's `header.php` uses `<?php language_attributes(); ?>` on the `<html>` tag rather than a hard-coded `lang` value.
- For block themes (Full Site Editing), go to Appearance → Editor → Templates → open the root template and ensure no hard-coded `lang` override is present in any HTML block.
- Verify with the axe browser extension after saving.
Does your site have this issue?
Run a free SEOLZ audit to find valid lang — and every other issue — across your whole site in minutes.
Scan my site freeFrequently asked questions
What is Valid lang?
Every HTML page has a `lang` attribute on the `<html>` tag (e.g. `<html lang="en">`) that tells browsers and assistive technologies what language the page is written in. When a page contains a passage in a *different* language, that section should also carry its own `lang` attribute (e.g. `<p lang="fr">`). The value must be a valid BCP 47 language tag — a standardised code like `en`, `en-US`, `fr`, `de`, or `zh-Hans`. An empty, misspelled, or made-up value (such as `lang=""` or `lang="english"`) fails WCAG Success Criterion 3.1.2 (Language of Parts).
Why does valid lang matter?
Screen readers like JAWS, NVDA, and VoiceOver automatically switch their text-to-speech voice and pronunciation rules based on the `lang` attribute. If the value is missing or invalid, the reader mispronounces words — sometimes so badly that the content becomes completely unintelligible to blind or low-vision shoppers. Beyond accessibility, WCAG 3.1.2 is a Level AA requirement, meaning failing it exposes your store to legal risk under laws such as the ADA in the US, the European Accessibility Act, and equivalent legislation elsewhere. Google also uses language signals to serve your pages to the right audiences, so correct `lang` values support your international SEO.
How do I fix valid lang?
Add a valid BCP 47 language code to every `lang` attribute on your pages so assistive technologies can read content in the correct language.
Authoritative references
- How to fix this specific rule — Deque/axe (rule reference)
- WCAG 2 overview — W3C WAI