Favorites

HTML lang Global Attribute

lang
HTML Global AttributeThis global attribute is supported by all modern browsers.
Updated 22nd November 2026

The lang attribute sets the language of an element's content, such as en or fr-CA. Screen readers, translation tools, hyphenation and fonts all use it.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The lang global attribute in HTML specifies the language of the element's content. It is a global attribute, meaning that it can be used on any HTML element. The lang attribute takes a BCP 47 language tag as its value, made of a language code that can be followed by a region or script, such as en-GB or zh-Hant. Common examples are en for English, es for Spanish, and fr for French.

The lang attribute is used for a variety of purposes, including:

  • Accessibility: Screen readers and other assistive technologies use the lang attribute to determine the language of the content being read, so that they can pronounce it correctly.
  • Typography: Browsers use the language to choose fonts and quotation marks, to hyphenate text with hyphens: auto, and for case conversion with text-transform.
  • Styling: The CSS :lang() pseudo-class selects elements by their language.
  • Translation: Browser translation tools use it to detect the language of the page.

It is important to note that the lang attribute is different from the xml:lang attribute. The xml:lang attribute is used in XML documents to specify the language of the content. In HTML documents, the lang attribute is preferred.

Here is an example of how to use the lang attribute:

<html lang="en">
<head>
  <title>My Website</title>
</head>
<body>
  <h1>This is my website.</h1>
</body>
</html>

In this example, the lang attribute is set to en, which means that the language of the content is English.

It is recommended to always specify the lang attribute on your HTML documents. This will help to ensure that your content is displayed and interpreted correctly by users and machines alike.

Syntax

<element lang="language_code">

Values

  • language_codeA BCP 47 language tag, such as en, en-GB, fr or zh-Hant. An empty string means the language is unknown.

Example

<p>This paragraph is English, but the language is not specifically defined.</p>
<p lang="en-GB">This paragraph is defined as British English.</p>
<p lang="fr">Ce paragraphe est défini en français.</p>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML lang global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.