How to fix html has lang on Adobe Commerce (Magento)

Add a valid `lang` attribute to the `<html>` element so browsers and assistive technologies know what language your page is written in.

Steps for Adobe Commerce (Magento)

  1. The root `<html>` tag is declared in `vendor/magento/module-theme/view/base/templates/root.phtml` — do NOT edit the core file.
  2. Instead, override it in your custom theme: copy the file to `app/design/frontend/<Vendor>/<Theme>/Magento_Theme/templates/root.phtml`.
  3. In the copied file, locate the `<html` tag. Magento outputs the language via a helper; ensure the tag includes `lang="<?= $htmlAttributes ?>"` or check that the `html_attributes` block renders the `lang` attribute correctly.
  4. Alternatively, in your theme's `default_head_blocks.xml` layout file you can add a `<html>` attribute node to inject the lang attribute dynamically using the store's configured locale.
  5. Set the store locale under Stores → Configuration → General → General → Locale Options → Locale.
  6. Run `bin/magento cache:flush`, then verify via View Source on the storefront.
Official Adobe Commerce (Magento) documentation ↗
<html lang="en">

What is html has lang?

Every web page starts with an `<html>` tag. The `lang` attribute on that tag (e.g., `<html lang="en">`) declares the primary human language of the page's content. Without it, screen readers, browsers, and translation tools have to guess the language — and they often guess wrong. This is a WCAG 2 Success Criterion 3.1.1 ("Language of Page") requirement, meaning it is part of an internationally recognised accessibility standard.

Screen readers use the `lang` attribute to select the correct voice engine and pronunciation rules — a missing or wrong value means a visually impaired customer hears your product descriptions read aloud in the wrong accent or language, making your store unusable for them. Failing WCAG 3.1.1 is an accessibility violation that can expose your business to legal risk under laws such as the ADA (US), the European Accessibility Act (EU), and the Equality Act (UK). Search engines also use the declared language to correctly index and serve your pages in the right regional search results, so a missing `lang` can quietly hurt your international organic traffic. It is also one of the fastest accessibility wins available — a one-line change that immediately satisfies a legal compliance checkpoint.

See the complete Html has 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 html has lang and every other issue across your whole site.

Scan my site free

Fix html has lang on another platform