Language Attribute


If the language of a web page is not identified in the HTML code, user agents cannot render the language properly. This will have a strong impact on people who use screen readers, people who find it difficult to recognize characters and alphabets, people who use text-to-speech software, and people who rely on captions for synchronized media.

How to Fix

  • Use the language attribute in the HTML element. (e.g. <html lang="en">)
  • If a web page uses several languages, the default text-processing language should be the language that is used the most.
  • If there are several languages that are used equally, the first language should be chosen as the default language.
  • For appropriate language codes, check the W3 Org Guide to Language Tags

Take it to the Next Level (AA)

Ensure that the language of each passage or phrase can be programmatically determined by a screen reader, except for proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the vernacular of the immediately surrounding text.

  • Use the language attribute on passages or phrases that are in a different language from most of the web content. For example, <p>This sentence is in English except for the following phrase which is in French: <span lang="fr">Bienvenue au Canada</span></p>.

External Resources

  1. Understanding Success Criterion 3.1.1 Language of Page (Level A)
  2. Understanding Success Criterion 3.1.2 Language of Parts (Level AA)