Skip to main content
SlapMyWeb
Fix Guide

How to Fix a Missing Lang Attribute

Declare the page's language so assistive technology pronounces it correctly.

Easy Medium Impact 5 min

A missing lang attribute means the html element does not declare what language the page is written in. Screen readers then apply the wrong pronunciation rules to the entire document, which makes it hard to follow. It is one attribute, it is a WCAG requirement, and roughly one in six audited sites is missing it.

Why It Matters

Without it, a screen reader may read English with Spanish phonetics, or vice versa. It is also a supporting signal for search engines deciding which audience a page serves.

How to Fix

1

Add lang to the html element

Use a BCP 47 tag: en, en-GB, ur, pt-BR. Include the region only when it changes spelling or pronunciation.
2

Mark passages in another language

A quotation or phrase in a different language takes its own lang attribute on the surrounding element.
3

Set dir for right-to-left languages

Arabic, Hebrew, Urdu and Farsi also need dir="rtl" so the layout direction is correct.
4

Check every template

The attribute is usually set once in a root layout, so a missing one often means an error page or an embed is rendered from a different template.

Code Fix

html
Before (broken)
<html>
After (fixed)
<html lang="en-GB">

Platform-Specific Instructions

WordPress

Themes should output language_attributes() in the html tag. A hardcoded html tag is the usual cause.

Next.js

Set it on the html element in the root layout; it does not appear by default.

Fixed that one.
Now find the rest.

A free audit ranks every issue on your site by the score points it costs — and links each one straight to its guide.

Run a free audit
Free foreverNo signupResults in 30s