How to fix valid lang on Adobe Commerce (Magento)

Add a valid BCP 47 language code to every `lang` attribute on your pages so assistive technologies can read content in the correct language.

Steps for Adobe Commerce (Magento)

  1. 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`.
  2. 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.
  3. 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.
  4. 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.
  5. Run `bin/magento cache:flush` after changes, then verify with the axe extension.
Official Adobe Commerce (Magento) documentation ↗
<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 -->

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).

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.

See the complete Valid lang guide for every platform and the full background.

Not sure if your Adobe Commerce (Magento) store has this?

Run a free SEOLZ audit — we’ll find valid lang and every other issue across your whole site.

Scan my site free

Fix valid lang on another platform