lang
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
).
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Career path
Full-Stack Engineer
A full-stack engineer can get a project done from start to finish, back-end to front-end.Includes 51 CoursesWith Professional CertificationBeginner Friendly150 hours - Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner Friendly7 hours