html-lang-attr-present

Page language is declared

automaticWCAG 3.1.1 (A)confidence: highseverity: seriousunderstandable

Checks that the default language of the page is programmatically declared.

Applies to. Applies to HTML documents with a root <html> element. The rule evaluates the document element only and does not iterate over child nodes. Non-HTML documents or documents without a document element are not applicable. A document shown in a frame (an <iframe> or <frame> of another page) is not applicable: the page's language is the top document's.

Expectation. The <html> element has a lang attribute. The lang attribute is not empty and its primary language subtag (the part before the first hyphen) is a registered language subtag, as ACT bf051a requires. A malformed later subtag (lang="fr-FR-!!") still identifies French, so it passes here; it is a markup validity error, not a missing language.

What a finding reports.

  • lang (a language that is not valid): the lang attribute's value, as written.

These data.details fields help to read and reproduce a finding. Apart from reasonCode and the few fields Output schema names as stable, they are not a stable contract: a field may be renamed or dropped in a minor release, so don’t build on them.

Examples

pass
<html lang="en">
<head><title>Page title</title></head>
<body>Hi</body>
</html>

A non-empty, syntactically valid language tag is declared.

fail
<html>
<head><title>Page title</title></head>
<body>Hi</body>
</html>

No lang attribute at all on <html>.

View source