# HTML lang attribute

Category: [International SEO](https://seo-geo-glossary.com/en/glossary/category/international-seo/) › [hreflang & language tags](https://seo-geo-glossary.com/en/glossary/category/international-seo/hreflang-language-tags/)

The **HTML lang attribute** declares the human language of an element's content. It usually sits on the `<html>` tag and holds a language tag such as `en` or `pt-BR`. Screen readers, browsers and spell checkers use it, and it applies to the element and everything inside it.

## How does the lang attribute work?

The value is a language tag following BCP 47, for example `fr`, `en-GB` or `zh-Hans`. An element without its own `lang` inherits the value of its parent. An empty value (`lang=""`) means the language is unknown.

Screen readers pick the pronunciation from it, and browsers choose hyphenation and spell-check dictionaries. CSS can target elements with the `:lang()` pseudo-class. Accessibility guidelines (WCAG) require that the language of a page and of passages in other languages can be determined by software.

The W3C recommends always setting `lang` on the `html` element. A passage in another language gets its own `lang` on the element around it. For plain HTML documents, `lang` alone is enough, and the W3C advises against using `<meta http-equiv="Content-Language">` to declare a page's language.

## Does the lang attribute matter for SEO?

Google states that it does not use hreflang or the HTML `lang` attribute to detect the language of a page. It uses its own algorithms. The attribute therefore matters mainly for accessibility and display. Linking language versions of a page to each other is the job of hreflang.

## Example

```html
<html lang="en">
  <body>
    <p>The book is titled <span lang="fr">Le Bon Usage</span>.</p>
  </body>
</html>
```

## Common mistakes

- A copied template still carries `lang="en"` on German content.
- The `lang` attribute is missing from the `html` tag.
- The value uses an underscore (`en_US`). BCP 47 joins subtags with a hyphen (`en-US`).

## FAQ

**Does lang replace hreflang?**
No. `lang` describes the language of one page or element. hreflang connects the language versions of a page.

**Can lang be set on a single paragraph?**
Yes. It is a global attribute and works on any element.

## Not to be confused with

- [hreflang](https://seo-geo-glossary.com/en/glossary/hreflang/index.md): links the language and regional versions of a page to each other. Google uses the annotations to show searchers the matching version.

## Related terms

- [hreflang](https://seo-geo-glossary.com/en/glossary/hreflang/index.md)
- [Content-Language header](https://seo-geo-glossary.com/en/glossary/content-language-header/index.md)
- [Language code (ISO 639-1)](https://seo-geo-glossary.com/en/glossary/language-code/index.md)
- [HTML](https://seo-geo-glossary.com/en/glossary/html/index.md)
- [HTML head](https://seo-geo-glossary.com/en/glossary/html-head/index.md)

## Sources

- [lang – Global attributes – MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang)
- [Declaring language in HTML – W3C Internationalization](https://www.w3.org/International/questions/qa-html-language-declarations)
- [Localized versions of your page – Google Search Central](https://developers.google.com/search/docs/specialty/international/localized-versions)
- [Understanding SC 3.1.1: Language of Page – W3C WAI](https://www.w3.org/WAI/WCAG22/Understanding/language-of-page.html)
- [Understanding SC 3.1.2: Language of Parts – W3C WAI](https://www.w3.org/WAI/WCAG22/Understanding/language-of-parts.html)
- [Tags for Identifying Languages (BCP 47, RFC 5646) – IETF](https://www.rfc-editor.org/rfc/rfc5646.html)

---

Last updated: October 8, 2026
URL: https://seo-geo-glossary.com/en/glossary/html-lang-attribute/
