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

  • A full-stack engineer can get a project done from start to finish, back-end to front-end.
    • Includes 51 Courses
    • With Professional Certification
    • Beginner Friendly.
      150 hours
  • Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Beginner Friendly.
      7 hours

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

  • A full-stack engineer can get a project done from start to finish, back-end to front-end.
    • Includes 51 Courses
    • With Professional Certification
    • Beginner Friendly.
      150 hours
  • Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Beginner Friendly.
      7 hours