In short. The HTML lang attribute declares the primary language of an element and, on html, the default language of the document.
Definition: The HTML
langattribute declares the primary human language of an element's contents and text-bearing attributes. On the roothtmlelement, it establishes the document's default language, which descendant elements inherit unless they declare another language.
Key facts
- The WHATWG HTML Standard requires a valid BCP 47 language tag or an empty value, which means the language is unknown.
- W3C's language declaration guidance places the default language on
html, covering both the document's head and body. - W3C's Language of Page explanation describes how identifying the language lets screen readers load the appropriate pronunciation rules.
- As of 17 October 2026, Google's multilingual site documentation says Google determines page language from visible content and ignores code-level language information such as
langfor that purpose.
How is a document's language declared?
W3C's Declaring language in HTML uses en for English and fr for French. These language tags follow BCP 47, a specification for standardized language identifiers.
The following example combines the guide's English document declaration with its French book-title example:
<!doctype html>
<html lang="en">
<head>
<title>Book title</title>
</head>
<body>
<p>The title is "<span lang="fr">Le Bon Usage</span>".</p>
</body>
</html>
English is the default for the title and paragraph. The span element declares French for the book title. The same guide recommends adding an enclosing element such as span when the text needing a language declaration has no surrounding markup.
Under the HTML Standard's inheritance rules, an ordinary child element with no language declaration inherits its parent's language. A declaration also applies to that element's attributes containing text. An explicitly empty lang="" value identifies the language as unknown, interrupting the inherited language.
Why does language matter, and how is it checked?
W3C's Language of Page explanation addresses success criterion 3.1.1 of the Web Content Accessibility Guidelines (WCAG): software must be able to determine a page's default human language. The explanation connects language identification to accurate pronunciation by screen readers. For a page containing several languages, it selects the language used most as the default; if usage is equal, it selects the first language used.
W3C's H57 technique supplies a concrete checking procedure: examine the document's html element, confirm that it has a lang attribute, and check that the value follows BCP 47 and reflects the page's primary language. Checking presence alone therefore leaves part of the procedure unfinished. A valid tag must also match the actual text.
How does lang relate to search and translated pages?
Google's multilingual site guidance distinguishes language detection from annotations for translated versions. It recommends a single language for the content and navigation on each page and separate URLs for different language versions. It describes hreflang, an annotation identifying language or region variants, as a way to help Google Search link to the appropriate version.
W3C's H57 technique places the default language on html. For translated documents, that declaration follows the primary language of each page.
Related terms
FAQ
Can I put lang only on body?
W3C's language declaration guide recommends html because a declaration on body leaves text in head outside its scope, including the document title.
Can lang contain a list of languages?
The HTML Standard requires a valid BCP 47 tag or an empty value. Declare the default language on html and use language attributes around passages in another language, following W3C's guidance above.
Sources
- WHATWG, "HTML Standard: The lang and xml:lang attributes", 16 October 2026
- W3C Internationalization, "Declaring language in HTML", undated
- W3C WAI, "Understanding SC 3.1.1: Language of Page", 9 March 2026
- W3C WAI, "H57: Using the language attribute on the HTML element", 12 January 2026
- Google Search Central, "Managing multi-regional and multilingual sites", 10 December 2025
Check how a page reads to answer engines. Open the GEO score analyzer