Skip to content

The document's <html> element has no lang attribute. Without it, screen readers can't pick the right pronunciation rules and search engines can't serve the page to the right locale — both an accessibility and an SEO concern.

This check flags the absence of the attribute only. An empty lang="" still counts as present; fixing the value is a separate concern from declaring the language at all.

Example

html
<!-- FIRES: no lang attribute. -->
<html>
  <head><title>Untitled</title></head>
  <body></body>
</html>

<!-- DOES NOT FIRE: lang declared. -->
<html lang="en">
  <head><title>Untitled</title></head>
  <body></body>
</html>

What to do

Add a lang attribute to the <html> tag with a valid BCP 47 language tag, e.g. lang="en", lang="en-GB", lang="fr".

Suppression

html
<!-- cofferdam-ignore: Html.MissingLangAttribute: intentionally omitted for this template -->
<html>

MIT License