Specify Lang Attribute
ID |
html.lang_attribute |
Severity |
low |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Html |
Tags |
accessibility, reliability |
Description
Flags the root <html> element when it has no lang (nor xml:lang) attribute, or when that
attribute is present but blank.
Rationale
Declaring the document’s primary language lets screen readers pick the correct voice and
pronunciation, lets spell-checkers and translation tools choose the right dictionary, and lets the
browser apply language-specific typographic rules. A page with no lang leaves all of that to a
guess, degrading accessibility and internationalisation.
<html> <!-- FLAW — no lang attribute -->
<head><title>Hi</title></head>
<body>...</body>
</html>
<html lang="en"> <!-- OK — language declared -->
<head><title>Hi</title></head>
<body>...</body>
</html>