Skip to content
WordPressRule: html-has-lang•Reviewed Oct 2026

Add the lang attribute to the html element in WordPress

The root `<html>` element must declare the document's primary language using a valid `lang` attribute.

What's wrong

Omitting the `lang` attribute causes assistive technology to default to the user's system language, mispronouncing words.

Who it affects

Screen reader users hear English text spoken using French or German phonetic engines, making text unintelligible.

How to fix on WordPress

In `header.php`, output `<html <?php language_attributes(); ?>>`.

Code example

Problematic Code
PHP
<!DOCTYPE html>
<html>
Recommended Accessible Code
PHP
<!DOCTYPE html>
<html <?php language_attributes(); ?>>

How to check your fix

Inspect the root element in DevTools Elements panel. Verify `<html lang="en">` (or matching store locale) is present.

Check if your site has this issue

Scan any public store page free against WCAG 2.2 AA in 30 seconds.

Your session has ended

Sign in again to carry on. Anything you typed on this page is kept.

Signed in another way? Use another method (opens a new tab)