Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

lang

The language of an element's content.

Syntax

<html lang="en">

Examples

A phrase in another language inside the text:

<p lang="en">The French say <i lang="fr">bon appétit</i> before a meal.</p>

The language affects hyphenation and quotes:

<style>
  p { width: 120px; hyphens: auto; border: 1px solid #ccc; }
</style>
 
<p lang="en">Extraordinarily <q>uncharacteristically</q> long words.</p>

Notes

Set the page language on <html>, and for passages in another language — on individual elements. The value is a language code: en, ru, de, optionally with a region: en-GB, pt-BR. Without lang, hyphens: auto does not work and screen readers use the wrong pronunciation.

See also

  • <html> — The root element of the page: `<head>` and `<body>` live inside it.
  • dir — The writing direction: left to right or right to left.
  • translate="no" — Tells automatic translators that the text should not be translated.

Related recipes

In the tutorial

  • Attributes — How HTML attributes work, the global attributes id, class, title, lang, hidden and style, boolean attributes and data attributes.

Thanks for reading!

Donate to the site — we work hard for you.