English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML lang attribute

ang global attribute participates in the definition of the element language. This language is the language that cannot be edited by the element, or the language that should be written by the editable element. The tag contains a single entry, and the format of the value is defined by the tag used to define the language (BCP47) IETF document definition. If the content of the tag is an empty string, the language is set to unknown. If the tag content is invalid, according to BCP47, it is set to invalid.

HTML Global Attributes

Online Example

This is a French paragraph demonstration:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML lang attribute usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<p>This is a paragraph.</p>/p>
<p>Ceci est un paragraphe.</p>/p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the lang attribute

Definition and Usage

The lang attribute specifies the language of the element content.

HTML 4.01 with HTML5differences

In HTML5you can use the lang attribute on any HTML element (it will validate on any HTML element. However, it may not be useful).
In HTML 4.01In HTML, the lang attribute cannot be used with <base>, <br>, <frame>, <frameset>, <hr>, <iframe>, <param>, and <script>.

Syntax

<element lang="language_code">

Attribute Value

ValueDescription
language_codeSpecifies the language code for the element content. Language Code Reference Manual. Language Code Reference Manual
HTML Global Attributes