---
title: "Add html lang attribute"
description: "The lang attribute on the html element tells browsers and assistive technology which language the page uses. Set it per locale, keep it accurate when content mixes languages, and make it match your hreflang values. A missing or wrong value breaks pronunciation, translation prompts and locale signals."
url: "https://seo-mcp.io/t/add-html-lang-attribute"
---

# Add html lang attribute

The lang attribute on the html element tells browsers and assistive technology which language the page uses. Set it per locale, keep it accurate when content mixes languages, and make it match your hreflang values. A missing or wrong value breaks pronunciation, translation prompts and locale signals.

## Prerequisites

- Access to the root layout or template

## Steps

1. **Set lang in the root layout** — Add lang to the html element with the locale of the page, not of the browser. Use the same tag format as your hreflang values.
   Check: curl -s your production domain/ | grep -o '<html[^>]*lang="[^"]*"' returns a valid BCP 47 tag.
2. **Handle mixed-language passages** *(general best practice)* — Wrap quotes or excerpts in another language with their own lang attribute. Do not change the document language for a single paragraph.
   Check: A page with a foreign quote contains a nested element with a different lang value.
3. **Align with hreflang and visible language** — Check that the lang value, the hreflang entry for the page and the visible content language agree on every locale template.
   Check: For each locale, the html lang, hreflang value and page copy all use the same language code.

## Source

@seo-mcp on 2026-10-19: https://developers.google.com/search/docs/specialty/international/localized-versions

Canonical: https://seo-mcp.io/t/add-html-lang-attribute
