The lang attribute on your <html> element tells browsers, search engines, screen readers and AI parsers which language your content is in. Missing or wrong lang doesn't crash anything but degrades accessibility (screen readers mispronounce), translation behaviour, and search-engine language detection. The fix is one attribute on one tag. This guide covers the right codes, multilingual patterns, and the hreflang connection.
en, fr, de) or language + region (en-GB, fr-CA, pt-BR). Rule: use the most specific code that genuinely matches your content.
lang="en"lang="en-GB"lang="en-US"lang="pt-BR"lang="pt"en-GB as the default just because the codebase is British. The lang should reflect what's in the content. Mislabelled lang confuses screen readers and translation tools.<!DOCTYPE html> <html <?php language_attributes(); ?>>
language_attributes() outputs lang="en-GB" (or whatever you set in Settings → General → Site Language). If your theme has a hardcoded <html lang="en">, replace it with language_attributes() so the value follows WP settings.
<html lang="{{ request.locale.iso_code }}">
request.locale.iso_code outputs the active locale (e.g. en, en-GB). For multi-locale stores via Shopify Markets, this automatically matches the visitor's locale.
export default function RootLayout({ children }) {
return (
<html lang="en-GB">
<body>{children}</body>
</html>
);
}
For internationalised routing, use the active locale from next-intl or the App Router's locale param.
Pages with mixed languages need lang attributes on the sections in different languages.
<html lang="en"> <body> <p>Welcome to our French bakery.</p> <p>Our signature: <span lang="fr">pain au chocolat</span>.</p> </body>Screen readers switch pronunciation mid-sentence based on the lang switch. Without it, "pain au chocolat" gets pronounced in English: "pain-aw-chock-o-lat" instead of the correct French pronunciation.
If you have separate URLs per language (most sites with proper i18n), link them with hreflang.
<head> of EVERY language variant:
<link rel="alternate" hreflang="en-GB" href="https://yourdomain.com/uk/page" /> <link rel="alternate" hreflang="en-US" href="https://yourdomain.com/us/page" /> <link rel="alternate" hreflang="fr-FR" href="https://yourdomain.com/fr/page" /> <link rel="alternate" hreflang="x-default" href="https://yourdomain.com/page" />Self-referencing (each variant links to itself plus all siblings) and
x-default for the fallback language are both required.
For full hreflang treatment see the hreflang fixes index.
curl -s https://yourdomain.com/ | grep -i '<html'Expected output:
<html lang="en-GB"> (or your chosen code).