3.1.1 Language of Page
Every HTML document must have a lang attribute on the <html>
element to indicate the primary language of the page. This helps assistive technologies such as screen readers to determine how to pronounce and interpret the text correctly.
The lang attribute should:
lang
attribute¶<html lang="en">
<head>
<title>Example Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
This check applies to all HTML documents.
Valid lang
attributes improve accessibility and usability in the following ways:
This section provides pass and fail examples for this check.
A document with a valid lang attribute
<html lang="fr">
<head>
<title>Exemple de page</title>
</head>
<body>
<p>Bonjour le monde !</p>
</body>
</html>
The lang="fr"
attribute correctly identifies the page as French.
A multilingual document with language changes
<p>This is an English paragraph.</p>
<p lang="es">Este es un párrafo en español.</p>
The lang="es"
attribute correctly marks the Spanish text.
Missing lang attribute on the <html>
element
<html>
<head>
<title>Example Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Without a lang attribute, screen readers may use the wrong pronunciation rules.
Empty or incorrect lang attribute
<html lang="">
<head>
<title>Example Page</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
An empty lang attribute is invalid and does not provide useful information.
Invalid language code
<html lang="english">
Ensure that there is a valid language code, english
is not a valid language code. The correct code is en
.
This check primarily benefits:
This section provides instructions for how to review and fix a lang attribute.
<html>
element.<html>
tag and confirm that there is a lang attribute with a valid value.Add a valid lang
attribute.
If the attribute is missing, add the correct language code to the <html>
tag:
<html lang="en">
Fix any empty or incorrect lang
attribute values.
Ensure that the lang
attribute contains a valid BCP 47 language code, such as:
en (English)
fr (French)
de (German)
es (Spanish)
zh-CN (Simplified Chinese)
If the page contains multiple languages, apply lang
attributes where needed:
<p lang="it">Questo è un testo in italiano.</p>
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Thu Mar 13 2025 10:53:35 GMT+0000 (Coordinated Universal Time)