Руководства по правилам axe
html-has-langseriousaxe-core 4.12.1

Fix html-has-lang axe errors

The document does not declare its default language, so assistive technology may choose the wrong pronunciation rules.

Кого затрагивает

Screen-reader users, people using translation or reading support, and users of browser language features.

Связь с WCAG

3.1.1 Language of Page (A)

Обнаружение

wcagc reports HTML documents whose root html element has no non-empty lang attribute.

Почему возникает эта ошибка

  • The document template omits lang entirely.
  • A client-side locale switch updates text but not document.documentElement.lang.
  • Static and server-rendered templates use different language defaults.

Проблемная разметка

<html>
  <body>...</body>
</html>

Исправленный код

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

Проверьте исправление вручную

Confirm that the declared language matches the page's primary natural language and changes correctly on localized routes. Mark substantial passages in another language separately.

Границы автоматизации

Automation can see whether lang exists, but this rule does not verify that the chosen language code matches the actual content.

Источники и стандарты

Метаданные правила и ссылка Deque генерируются из axe-core 4.12.1. Ссылка W3C ведёт на нормативное руководство WCAG для соответствующего критерия.

Вопросы разработчиков

What if a page contains several languages?

Set the primary page language on html, then add lang to passages whose language differs from the surrounding content.

Does lang help only screen readers?

No. It also supports translation, spell-checking, speech tools and other browser language features.

Проверьте отрисованную страницу

Одно нарушение редко встречается в одиночку

Запустите проверку страницы в wcagc, чтобы найти это правило, связанные проблемы WCAG, затронутые селекторы и пункты, требующие ручной оценки.

Проверить страницу