HTML global attributeGlobal attributes

lang

The language of the element’s content, for example pl or en.

Applies to
All HTML elements
On this page

Example

#
HTML
<p lang="en">Quote of the day: <q>Less is more.</q></p>
<p lang="pl">Cytat dnia: <q>Mniej znaczy więcej.</q></p>
<p lang="de">Zitat des Tages: <q>Weniger ist mehr.</q></p>
Preview

Definition and usage

#

The lang attribute says what language the content of the element and its descendants is in. The most important place is the <html lang="en"> tag, which sets the language of the whole page.

Many things depend on this information: pronunciation in screen readers, hyphenation in CSS (hyphens: auto), automatic translation, and even the shape of the quotation marks generated by <q>.

Mark passages in another language separately, for example a quote in Polish inside English text. The value is a language code following the BCP 47 standard: pl, en, en-GB, pt-BR.

Syntax

#
Syntax
<element lang="language-code">…</element>

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Always set lang on the <html> element. A missing attribute is one of the most common accessibility errors.
  • A language code is not a country code: for English you write en, not uk or gb.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.