--- title: "lang attribute on inline content" category: i18n status: required url: https://webspecification.com/spec/i18n/lang-attribute/ updated: "2026-05-29T18:54:03.000Z" sources: - title: "WCAG 3.1.2 — Language of Parts (Level AA)" url: "https://www.w3.org/WAI/WCAG22/Understanding/language-of-parts.html" publisher: "W3C" - title: "W3C i18n — Declaring language in HTML" url: "https://www.w3.org/International/questions/qa-html-language-declarations" publisher: "W3C" - title: "MDN — The lang global attribute" url: "https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang" publisher: "MDN" source_repo: undefined licence: CC-BY-4.0 --- # lang attribute on inline content > Mark passages, phrases, and inline elements that differ from the document language with a lang attribute. WCAG 3.1.2 requires it so assistive tech can switch pronunciation. ## What it is `lang` is a global HTML attribute that names the natural language of the element's content. The root document language belongs on `` (covered by [the html lang attribute spec page](/spec/foundations/html-lang/)). This page is about the *other* `lang` declarations — the ones you add to spans, paragraphs, quotes, and any inline content whose language differs from the page default. ```html
The German verb verschlimmbessern means to make something worse by trying to improve it.
``` ## Why it matters WCAG 2.4.2 Level A requires a page-level language. [WCAG 3.1.2 Level AA](https://www.w3.org/WAI/WCAG22/Understanding/language-of-parts.html) requires per-part language declarations for any passage or phrase whose language differs from the surrounding text. The benefits are concrete: - **Screen readers** switch voice and pronunciation rules. VoiceOver reads a French sentence with a French voice when it sees `lang="fr"`; without it, it mangles the words with the document-language voice. - **Browsers** apply the correct spellcheck dictionary, font fallback, hyphenation rules, and quotation marks. - **Search engines and translation tools** know which spans to leave alone and which to translate. - **CSS** can target language with the `:lang()` pseudo-class — useful for typography and quotation marks. ## How to implement Use [BCP 47](https://www.rfc-editor.org/info/bcp47) tags, the same tagging system used for `hreflang`. Language subtag first, optional script and region after. ```html
Je pense, donc je suis.
The motto per aspera ad astra is Latin.
The Japanese term 改善 (kaizen) means continuous improvement.
``` Rules of thumb: - **Mark the smallest correct element.** A `` around a foreign phrase is fine. - **Mark scripts when relevant.** `zh-Hans` vs `zh-Hant` matters for font selection. `ja-Latn` distinguishes romanised Japanese from kanji. - **Do not mark proper names** that are widely used in the page language ("Paris" in an English text does not need `lang="fr"`). - **Quotes and citations** are good candidates — `` and `` change quotation-mark glyphs via the browser.
## Common mistakes
- Tagging every loanword. "Café" and "ad hoc" in English text are English now.
- Using invalid codes like `lang="english"` or `lang="UK"`. Use `en` or `en-GB`.
- Setting `lang=""` (empty) on an element to "unset" it — that is only valid on `` when the language is genuinely unknown.
- Forgetting the script subtag for CJK content, which causes wrong font rendering.