WCAG 2.2 Fix Guide

How to Fix Missing Lang Attribute on HTML Element

The <html> element at the top of every page must have a lang attribute that identifies the language of the page content. For example: <html lang='en'> for English or <html lang='pt'> for Portuguese.

WCAG 2.2 Success Criterion 3.1.1 (Level A) axe-core: html-has-lang

Why this matters

Screen readers use the lang attribute to choose the correct pronunciation engine. Without it, a screen reader may read English text with the wrong accent or mispronounce words entirely. It also helps translation tools and search engines understand your content.

Code examples

✗ Incorrect — fails WCAG
<!DOCTYPE html>
<html>
<head>...</head>
✓ Correct — passes WCAG
<!DOCTYPE html>
<html lang="en">
<head>...</head>

<!-- Portuguese -->
<html lang="pt-BR">

<!-- Spanish -->
<html lang="es">

How to fix it — step by step

  1. 1
    Add lang='en' (or your language code) to the <html> element
  2. 2
    Use the correct BCP 47 language tag — 'en' for English, 'pt-BR' for Brazilian Portuguese, 'es' for Spanish
  3. 3
    For WordPress: most themes add this automatically via language_attributes() in header.php
  4. 4
    If your page has sections in a different language, add lang= to that specific element
  5. 5
    Check your lang value is correct — lang='en' on a Spanish page is also a violation
Reference: WCAG 2.2 Success Criterion 3.1.1 (Level A)

Test it for free

Use WebPossum to automatically detect this violation and every other WCAG 2.2 issue on your site. Free, instant, no signup required.