HTML lang Global Attribute


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 an ISO language code as its value. 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.
  • Search engines: Search engines use the lang attribute to improve their search results. For example, if you search for a keyword in English, a search engine will be more likely to return results that are in English.
  • Content negotiation: Servers can use the lang attribute to negotiate the language of the content that is sent to the client. This is useful for websites that support multiple languages.

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">
  <title>My Website</title>
  <h1>This is my website.</h1>

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.


<element lang="language_code">


  • language_codeSpecifies the language code for the content of the element.


<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>

Browser Support

The following table will show you the current browser support for the HTML lang Global Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 14th October 2023