- Courses
- HTML
- HTML top level tags
- <html>
- Significance of lang in <html>
Why is it important to specify the lang
attribute in the <html>
element?
Specifying the lang
attribute helps screen readers determine the correct language to announce.
Providing a lang
attribute with a valid language tag ensures that the language used is correctly identified, which helps screen readers announce the content properly. It also ensures that important metadata like the page's title is announced correctly, enhancing accessibility for users who rely on assistive technologies.
<html lang="en">
<head>
<title>Example Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>