We'd like to set Google Analytics cookies to learn how people use the Knowledge Base, so we can improve it. We set them only if you accept.

Skip to main content
Digital Accessibility Knowledge Base

html-lang-valid

Web validation

The <html> element must include a valid lang attribute that accurately declares the primary language of the page.

The lang attribute helps assistive technology, search engines, and browsers present content with correct pronunciation, spell-checking, and glyph selection. When the attribute is missing or invalid, people who rely on text-to-speech or translation tools may hear mispronunciations or receive incorrect results, and search engines can mis-index the page.

Pass Patterns

A complete page with a valid primary language

The document’s root element uses the two-letter tag en that is part of the ISO 639-1 list. The lang="en" follows the BCP 47 format and matches the page language, so assistive technology can announce content correctly.

HTML
<!DOCTYPE html>
<html lang="en">
    ...
</html>

Specifying a dialect

fr-CA identifies Canadian French, a valid subtag combination that helps screen readers switch voices automatically.

HTML
<!DOCTYPE html>
<html lang="fr-CA">
    ...
</html>

Fail Patterns

Invalid language value due to a nonexistent language tag

english is not an ISO 639 code, so the user agent cannot map it to a language engine.

HTML
<html lang="english">
    …
</html>

Invalid dialect subtag separator

The separator between the language tag and its dialect subtag must be a hyphen (-), not an underscore.

HTML
<html lang="en_GB">
    …
</html>

ACT Rules

Try It Yourself

Screen readers read and pronounce text in different languages based not only on the lang attribute, but also on the installed language packages and the operating system’s default language. To ensure consistent test results across all users, the tests will focus on validating allowed lang values from Set 1 of the ISO 639 standard.

Inspecting the browser dev-tools

  1. Open the page in a browser.
  2. Open Developer Tools and switch to the Elements panel.
  3. Select the root <html> element.

Expected result: The primary language subtag of the lang value (for example, fr in fr-CA) is included in the ISO 639 list.

Actual result: The value of the lang attribute is not included in the ISO 639 list.

FAQ

How does this issue relate to 3.1.1 Language of Page?

SC 3.1.1 requires that the default human language of each page be programmatically determinable. A valid lang attribute satisfies this requirement.

Why is this issue marked as Serious?

Incorrect or missing language metadata disrupts pronunciation, translation, and spell-checking, creating significant comprehension barriers for people who use assistive technology or who depend on machine translation. Because the problem affects every user on the page and impedes understanding, it warrants a Serious severity.

Standards and Regulations

StandardSuccess CriterionReference
WCAG 2.23.1.1 Language of Page (A)The default human language of each web page can be programmatically determined.
EN 301 5499.3.1.1 Language of PageSame as the WCAG text.

Personas impacted by this issue