Home / Knowledge Base / Why Every Page Must Declare Its Language

Why Every Page Must Declare Its Language

Every web page must identify its primary language so that assistive technologies can interpret and present the content correctly. When the language is missing or incorrect, users who rely on screen readers may hear text pronounced using the wrong language rules, making the content difficult or impossible to understand.

What the lang Attribute Does

The lang attribute tells browsers and assistive technologies which human language the content is written in.

This information is used to:

  • Apply the correct pronunciation rules for speech output
  • Select appropriate Braille translation tables
  • Improve spellchecking, translation, and language-aware processing
  • Enable language switching within a page where supported

The lang attribute must be placed on the root <html> element to define the primary language of the page.

WCAG Success Criterion

3.1.1 Language of Page (Level A)

The default human language of each web page can be programmatically determined.

Programmatically determined means that software, such as browsers and assistive technologies, can reliably detect the language through markup, not by guessing or auto-detecting.

This is a Level A success criterion and is required for basic WCAG conformance.

How to Fix the Problem

Specify the primary language on the <html> element

Add a valid lang attribute to the opening <html> tag.

<html lang="en">
  <!-- document head and body -->
</html>

The value must match the actual language of the page content.

Language codes are case-insensitive, but the conventional format uses lowercase language codes and uppercase region codes.

Using language variants (optional)

You may specify regional or dialect variants using standard BCP 47 language tags, for example:

<html lang="en-US">
<html lang="fr-CA">

This allows assistive technologies to apply more precise pronunciation rules when supported.

Handling language changes within a page

If part of the content is written in a different language, explicitly mark that section.

<p>
  Text in one language
  <span lang="es">texto en otro idioma</span>
</p>

Language attributes are inherited by child elements unless overridden.
You should only add a lang attribute when the language genuinely changes, not for isolated foreign words, names, or loanwords that do not affect pronunciation.

Right-to-left languages

The lang attribute does not imply text direction.

For right-to-left languages such as Arabic or Hebrew, you must also specify the dir attribute.

<p lang="ar" dir="rtl">Arabic text here</p>

Directionality must be handled independently of language.

Why This Matters

Screen reader users configure a default language in their assistive technology.
If a page does not specify its language, or specifies the wrong one, the screen reader will:

  • Assume the user’s default language
  • Use incorrect pronunciation rules
  • Produce output that may sound garbled or unintelligible

Screen readers do not reliably auto-detect language, especially for short text or mixed-language content. They rely on explicit markup to switch pronunciation rules and processing behaviour.

Using an incorrect language value (for example, lang="en" on a Spanish page) is often worse than omitting the attribute, because it forces the wrong language rules to be applied consistently.

Common Real-World Failure Patterns

  • CMS templates hard-code lang="en" regardless of page language
  • Pages translated visually but not updated in markup
  • Language declared on <body> instead of <html>
  • Incorrect or invalid language codes
  • Overusing lang for single foreign words or proper nouns

These failures commonly appear in audits and directly affect assistive technology output.

Rule Description

The <html> element must contain a valid lang attribute that identifies the primary language of the page. When the language changes within the content, those changes must be identified at the element level.

How to Test Language of Page

  1. Inspect the opening <html> element
  2. Confirm a lang attribute is present
  3. Verify the language code is valid and well-formed
  4. Confirm the declared language matches the visible content
  5. Check that any language changes within the page are explicitly marked

If the language cannot be reliably detected from markup, the criterion is not met.

Wrapping Up

The lang attribute is a small but essential requirement. It allows assistive technologies to apply the correct language rules instead of guessing, which directly affects comprehension.

Every page must declare its language, and it must be correct. Doing so is one of the simplest accessibility fixes, and one of the most impactful for screen reader users.

Want to test against all WCAG success criteria?

Stay compliant. Avoid fines. WebYes reviews your entire website so you don't have to worry.

Sign Up for Free Now