HTML has lang attribute

high

html_lang

Checks that the HTML element has a lang attribute.

What does this rule check?

The lang attribute on the <html> element declares the primary language of the page. Screen readers use this to select the correct pronunciation rules.

Why is this important?

Without a lang attribute, screen readers may use the wrong language pronunciation, making content unintelligible. It's also required by WCAG 2.0 Level A.

How to fix

Add a lang attribute to the <html> element with the correct BCP 47 language code.

Examples

Incorrect
<html>
  <!-- No lang attribute -->
</html>
Correct
<html lang="en">
  <!-- English content -->
</html>

Agent fix snippet

Copy this snippet and paste it into your AI coding agent to fix this issue automatically.

Add lang attribute to the <html> tag:

<html lang="en">

Use the correct BCP 47 code: en, pt-BR, es, fr, de, ja, etc.