In short
Ahrefs flags "HTML lang attribute invalid" when the lang value on the <html> tag isn't a valid BCP 47 language tag. Typical mistakes are english, en_US with an underscore, or en-UK. Google doesn't use the lang attribute to detect language, but screen readers use it for pronunciation, and browsers use it for translation prompts and hyphenation. Use a short code like en or en-US.
The lang attribute tells browsers and assistive tools what language a page is in. It has to be a real language code.
Correct format
| Invalid | Valid |
|---|---|
lang="english" |
lang="en" |
lang="en_US" |
lang="en-US" |
lang="en-UK" |
lang="en-GB" |
lang="bd" (country) |
lang="bn" (Bengali) |
lang="" |
lang="en" |
Why it matters: WCAG 2.2 success criterion 3.1.1, Language of Page, is a level A requirement, the most basic level of accessibility.
Where to set it
WordPress: Settings > General > Site Language. The theme outputs it through language_attributes().
Shopify: the store's default language, output in theme.liquid via request.locale.iso_code.
Webflow: Site settings > Localization, for the primary locale.
Wix: the site language in Settings > Language & Region.
Custom builds: set it in the root HTML template, for example <html lang="en"> in index.html for a Vite app.
This guide isn't affiliated with or endorsed by Ahrefs.
Related issues
Sources and references
Google Search Central, Managing multi-regional and multilingual sites

About the author
Nazmul Nikhil
Head of SEO & Assistant Manager, Digital Marketing at Notionhive
SEO and AI search consultant in Dhaka, Bangladesh, helping small and mid-size businesses in the USA, UK, Australia and Canada.



