What is a lang attribute?

Question

What is the purpose of a lang attribute?

Answer

A web page's <html> element must have an appropriate lang attribute. The default human language of each Web page can be programmatically determined.  The purpose of the lang attribute is to define the default language of text in the page, as well as in the content of an element. Distinguishing the language of the page provides screen reader users the ability to switch languages (when/if there is a portion of text in a language differing from the rest of the web page) to ensure the correct accent and pronunciation is communicated properly.

E.g. Add `lang="en"` to the `<html>` element if the page's primary language is English.

Explore the Guided Manual WCAG Audit Tool from Accessible Web to evaluate the lang attribute on web pages.

Free Tools to Continue Learning

Accessible Web Company Logo

Accessible Web RAMP

Monitor your website and manage your progress towards WCAG conformance.

Accessible Web Company Logo

Accessible Web Academy

Career specific courses to help power up your accessibility knowledge.