HTML lang Attribute Tutorial

In this section, we will learn what the lang attribute is and how to use it in HTML.

HTML lang Attribute Definition and Usage

For HTML elements that have text content in their body, we can use the `lang` attribute to set the language that the text is written in.

For example, if the content is written in French, then the value of this attribute would be “fr”.

The value we set for the `lang` attribute helps search engines to realize what the content’s language of that element is so they know for what type of users and language the target content is useful to show in SERPs (Search Engine Result Pages).

HTML lang Attribute Syntax

<element lang = “value”>

HTML lang Attribute Values

The value we set for this attribute is taken from the Language Standard Code 

For example, if the content is written in English, then the value is “en”.

Example: using lang attribute in HTML

See the Pen using lang attribute in HTML by Omid Dehghan (@odchan1) on CodePen.

Leave a Reply