Skip to content

missing-html-lang

Added in NEXT_DJANGOFMT_VERSION · Related issues · View source

What it does

Checks for <html> tags that do not declare a lang attribute.

Why is this bad?

The lang attribute on <html> declares the primary language of the document. Screen readers use it to select the correct pronunciation rules, and search engines use it to index the page for the right audience.

A lang attribute wrapped in a Jinja conditional (e.g. {% if %}lang="en"{% endif %}) is treated as present, to avoid false positives on dynamic templates.

Example

<html>
</html>

Use instead:

<html lang="en">
</html>

References