Skip to main content
No Result Found

html-has-lang

<html> element must include a lang attribute with a valid value.

Severity: Serious

Description

The lang attribute in the HTML document element (e.g., <html lang="en">) is essential as it indicates the primary language used in the document, allowing screen readers to switch their pronunciation libraries accordingly. The lang attribute accepts language codes based on the ISO 639 standard, which represent different languages and language variants. Some common examples of language codes include - English: en, French: fr and Spanish: es etc.

Why is it important?

The lang attribute plays a critical role in ensuring accurate pronunciation and comprehension of web content for users with disabilities, particularly those who rely on screen readers. When omitted or incorrectly set, screen readers may default to the user’s preferred language setting, potentially mispronouncing content intended for a different language. This leads to confusion and difficulty in understanding for screen reader users. For example, a webpage intended to be in French might be read out in English if the lang attribute is not specified.

How to fix?

Add a “lang” attribute to the <html> element with a value corresponding to the language of the webpage. In cases where an element within the page’s body employs a different language than the one specified in the <html> element, it is possible to override the language definition by utilizing the language attribute on specific elements as well.

References

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle