Using the language attribute on the HTML element

Important Information about Techniques

See Understanding Techniques for WCAG Success Criteria for important information about the usage of these informative techniques and how they relate to the normative WCAG 2.1 success criteria. The Applicability section explains the scope of the technique, and the presence of techniques for a specific technology does not imply that the technology can be used in all situations to create content that meets WCAG 2.1.

Applicability

HTML

This technique relates to Success Criterion 3.1.1: Language of Page (Sufficient).

Description

The objective of this technique is to identify the default language of a document by providing the lang attribute on the html element.

Identifying the language of the document is important for a number of reasons:

HTML uses the lang attribute of the html element.

Examples

Example 1

This example defines the content of an HTML document to be in the French language.

<!DOCTYPE>
<html lang="fr"> 
<head>
  <title>document écrit en français</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>  
<body>     
	...document écrit en français...   
</body>
</html>

Resources

Resources are for information purposes only, no endorsement implied.

Tests

Procedure

Examine the html element of the document.

  1. Check that the html element has a lang attribute.
  2. Check that the value of the lang attribute conforms to BCP 47: Tags for the Identification of Languages or its successor and reflects the primary language used by the Web page.

Expected Results

  • Checks #1 and #2 are true.