---
title: Valid HTML lang Value | Accessibility Rule
description: "<html> element must have a valid value for the lang attribute"
source_url:
  html: https://testingbot.com/support/accessibility/web/rules/html-lang-valid
  md: https://testingbot.com/support/accessibility/web/rules/html-lang-valid/index.md
---
# Ensure the lang attribute of the \<html\> element has a valid value

Rule ID: html-lang-validUser Impact: seriousGuidelines: WCAG 2.0

Ensure that the `<html>` element includes a `lang` attribute with a valid language code to specify the primary language of the document.

## About This Rule

This rule ensures that the `<html>` element contains a valid `lang` attribute, facilitating proper language identification for assistive technologies and enhancing accessibility for multilingual users.

## Why It Matters

Screen readers and other assistive technologies rely on the `lang` attribute to determine the language of the content, enabling accurate pronunciation and interpretation. Without this attribute, or if it contains an invalid value, users may experience incorrect pronunciation, leading to confusion and a diminished user experience.

## How to Fix

To specify the primary language of your document:

- Add a `lang` attribute to the `<html>` element with a valid language code. For example, for English: 

    <html lang="en">
      <!-- document head and body -->
    </html>

- For regional dialects, use appropriate language codes, such as "en-US" for American English or "fr-CA" for Canadian French. 
- If the document contains sections in different languages, specify the language for those sections using the `lang` attribute on the relevant elements: 

    <p>This is an English paragraph.</p>
    <p lang="es">Este es un párrafo en español.</p>

- For languages written right-to-left, also include the `dir` attribute: 

    <p lang="ar" dir="rtl">نص باللغة العربية هنا</p>

## Other Rules

Interested in other web accessibility rules? Please see these other rules:

- [html-xml-lang-mismatch](https://testingbot.com/support/accessibility/web/rules/html-xml-lang-mismatch)
- [image-alt](https://testingbot.com/support/accessibility/web/rules/image-alt)
- [input-button-name](https://testingbot.com/support/accessibility/web/rules/input-button-name)
- [input-image-alt](https://testingbot.com/support/accessibility/web/rules/input-image-alt)
- [label](https://testingbot.com/support/accessibility/web/rules/label)
