The lang attribute on the <html> tag tells every consumer of the page - browser, screen reader, Google, translation services - what the primary language is. It is one short attribute that controls how a blind user hears the site and how Google ranks it.
Why this matters
Screen readers like NVDA and VoiceOver use lang to choose the correct pronunciation engine. A page written in English with <html lang="en"> is read with English phonetics; without the attribute (or worse, defaulted to a different language), the same text is mispronounced into noise. For a Hebrew site without lang="he", Hebrew letters can be pronounced with Latin phonetics - rendering the page unintelligible to blind users.
This is a international accessibility guidelines Level A requirement, 3.1.1 Language of Page. 3.1.2 Language of Parts covers language switches inside content (<span lang="fr"> around French quotes inside an English page). For SEO, Google uses lang as a language targeting signal - a page with lang="en-GB" tends to appear for British English searches. Translation tools (Google Translate, dictionary popups) also rely on lang to identify the source language.
How to detect
View source on the home page. The first line of HTML should be:
<html lang="en-US">Or for a Hebrew site:
<html lang="he-IL" dir="rtl">If you see <html> with no attribute, or lang="", or the wrong language, there is a problem. Tools: axe DevTools, Lighthouse and WAVE all flag this. RankPlus reads the home page DOM and checks the lang value.
How to fix
- Visit Settings > General > Site Language. Confirm the right language is set. This drives what
language_attributes()in PHP returns. - Inspect
header.phpin the active theme (wp-content/themes/THEME/header.php). The opening line must be:
not just<html <?php language_attributes(); ?>><html>. - For block themes (FSE) on WordPress 6.0+: edit via Appearance > Editor > Templates > Header.
- Verify no
functions.phpor plugin removes the filter:
If agrep -rn "language_attributes" wp-content/themes/ wp-content/plugins/remove_filteror empty return appears, locate and remove it. - Flush page cache (W3 Total Cache, WP Rocket, LiteSpeed) after the change - cached pages still ship the old language.
- For multilingual sites (WPML, Polylang, TranslatePress): the plugin handles
langper language version. Verify the plugin is active and that every page has a valid locale. - For inline foreign-language text (a Hebrew quote inside an English post), wrap with
<span lang="he">...</span>.
Common mistakes
- An aggressive minifier stripping attributes: some optimisation plugins drop
lang. Check the rendered HTML. - Removing
language_attributes()for "cleaner code": disables the entire mechanism. - Using legacy codes like
lang="iw"for Hebrew (IANA deprecated this in favour ofhe). - Forgetting
dir="rtl"on Hebrew/Arabic: even withlang="he", the browser also needsdir="rtl"to render text correctly.language_attributes()emits both. - An out-of-date multilingual plugin: a stale WPML can render the default
langon all pages.
Verifying the fix
View source on home, single post and category pages. All should start with <html lang="..."> matching the actual content language. Run Lighthouse - the Accessibility item "document has a valid lang attribute" should pass. RankPlus turns green.
hreflang alongside lang - it tells Google there are language alternatives of the same content. <link rel="alternate" hreflang="en" href="...">.