Technical SEO Important

HTML Lang Attribute

Why it matters

The lang attribute on <html> declares the page language to screen readers, browsers and other HTML parsers (WCAG 3.1.1). Google itself reads language from the visible text.

What we check

Whether the <html> tag has a lang attribute declaring the page's content language.

How to fix

  1. 1 Add lang attribute to your <html> tag (e.g., <html lang="en">).
  2. 2 Use ISO 639-1 two-letter codes.
  3. 3 For regional variants, use subtags (e.g., lang="en-US").

Example

lang on the <html> element

<!DOCTYPE html>
<html lang="en">       <!-- English -->
<html lang="en-GB">    <!-- English, United Kingdom -->
<html lang="pt-BR">    <!-- Portuguese, Brazil -->

How to check it yourself

  1. View the page source: the <html> tag near the top should carry a lang attribute.
  2. In the browser console, run document.documentElement.lang. An empty string means the attribute is missing.
  3. Confirm the code matches the language of the visible text and the codes in your hreflang links. A German translation that still declares lang="en" sends conflicting signals.

FAQ

Does Google use the lang attribute?

No. Google's multi-regional documentation says it "uses the visible content of your page to determine its language" and does not use "code-level language information such as lang attributes."

Then why set it?

Accessibility and every other consumer of your HTML. WCAG 2.2 success criterion 3.1.1 (Level A) requires the default language of each page to be programmatically determinable. Screen readers use it to pick the right pronunciation, and browsers use it to render characters and scripts correctly.

What is the difference between lang and hreflang?

lang declares the language of the page itself. hreflang, on link rel="alternate" tags, points to translated versions of the page at other URLs. Multilingual sites need both, with matching codes.

Should I use en or en-US?

Use the bare language code unless the regional variant matters for the content, such as spelling, currency or units. BCP 47 allows both, and a screen reader can use the region subtag to choose an accent.

What about pages that mix languages?

Declare the main language on <html> and mark passages in another language with their own lang attribute, for example <blockquote lang="fr">. WCAG 2.2 covers this in success criterion 3.1.2, Language of Parts (Level AA).