Goal
Ensure that the default language of each web page is programmatically identified so that screen readers and other assistive technologies can read content correctly.
Key Points
- The
lang
attribute on the<html>
element defines the page language. - For content in a different language, use the
lang
attribute on that element. - Helps screen readers choose the correct pronunciation and speech rules.
- Important for multilingual sites and content snippets in another language.
Short Summary
Declaring the language allows assistive technologies to accurately interpret and read text, improving comprehension for users who rely on screen readers.
Example Issues and Fixes
Missing Page Language
Fail
<html>
<head>
<title>Welcome</title>
</head>
<body>
<p>Hello, welcome to our website!</p>
</body>
</html>
Pass
<html lang="en">
<head>
<title>Welcome</title>
</head>
<body>
<p>Hello, welcome to our website!</p>
</body>
</html>