lang

board7161871779's avatar
Published Mar 26, 2025
Contribute to Docs

The lang attribute is a global HTML attribute used to set the language of the element’s content. It helps browsers, screen readers, and translation tools understand how to process and present the text.

Syntax

<element lang="language-code"></element>
  • language-code: Sets the language code for the element’s content.

Example

The following example demonstrates the usage of the lang attribute:

<html lang="en">
<head>
<title>My Website</title>
</head>
<body>
<p>Welcome to my website!</p>
</body>
</html>

The above code sets the language of the <html> element’s content to English (en).

All contributors

Contribute to Docs

Learn HTML on Codecademy