---
title: HTML lang Attribute | Accessibility Rule
description: "<html> element must have a lang attribute"
source_url:
  html: https://testingbot.com/support/accessibility/web/rules/html-has-lang
  md: https://testingbot.com/support/accessibility/web/rules/html-has-lang/index.md
---
# Ensure every HTML document has a lang attribute

Rule ID: html-has-langUser Impact: seriousGuidelines: WCAG 2.0

Ensure that the `<html>` element includes a `lang` attribute 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, 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-lang-valid](https://testingbot.com/support/accessibility/web/rules/html-lang-valid)
- [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)
