Default language


The default language of a web page is the primary language in which its content is written. It is declared in HTML with the lang attribute on the document's root element. Without this declaration, screen readers do not know which pronunciation rules to apply and read the text with the accent of the language configured on the user's system.


A French website without lang="fr" on its <html> tag. The screen reader reads all content using the phonetic rules of the language configured on the user's system. Every French word, pronounced like English.

#What the lang attribute does

The lang attribute on <html> tells browsers and assistive technologies what language the content is written in. When a screen reader like NVDA or VoiceOver encounters lang="fr", it loads French pronunciation rules. Braille displays apply the corresponding contraction tables. On the browser side, this attribute determines the quotation marks for <q>, the date format in input fields, and the language for spell-checking.

The implementation comes down to a single attribute:

<html lang="fr">

The code uses the BCP 47 standard: fr for French, en for English, de for German.

#A level A criterion, always overlooked

WCAG criterion 3.1.1 requires that the default language of each page be determinable programmatically. Level A: the bare minimum. RGAA restates this requirement in criteria 8.3 and 8.4.

The absence of a declared language ranks among the 6 most frequent errors detected by WebAIM Million 2025 across one million home pages.

#The error nobody sees

Putting lang on <body> instead of <html>. The <head> is not covered. Yet the page's <title>, often the first element read by a screen reader, is located in the <head>.

<!-- ❌ Does not cover the <head> -->
<html>
  <head><title>My site</title></head>
  <body lang="fr">...</body>
</html>
 
<!-- ✅ Covers the entire document -->
<html lang="fr">
  <head><title>My site</title></head>
  <body>...</body>
</html>

Another pitfall: language codes are not country codes. Luxembourgish is lb, not lu (which designates Luba-Katanga). And fr-FR is useful only to distinguish French from France from French from Canada (fr-CA). For most websites, fr is sufficient.

#In summary

Add lang to <html>, not to <body>. Use a valid BCP 47 code. One line of code, a level A criterion, and one of the quickest accessibility fixes to deploy.

Share this article

Learn more