Website Spec
← Internationalisation
Required

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 <html lang="…"> (covered by the html lang attribute spec page). 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.

<p>The German verb <span lang="de">verschlimmbessern</span> means to make
something worse by trying to improve it.</p>

Why it matters

WCAG 2.4.2 Level A requires a page-level language. WCAG 3.1.2 Level AA requires per-part language declarations for any passage or phrase whose language differs from the surrounding text. The benefits are concrete:

How to implement

Use BCP 47 tags, the same tagging system used for hreflang. Language subtag first, optional script and region after.

<html lang="en-GB">
  <body>
    <blockquote lang="fr">
      Je pense, donc je suis.
    </blockquote>
    <p>The motto <i lang="la">per aspera ad astra</i> is Latin.</p>
    <p>The Japanese term <span lang="ja">改善</span>
       (<span lang="ja-Latn">kaizen</span>) means continuous improvement.</p>
  </body>
</html>

Rules of thumb:

Common mistakes

Sources