
The HTML lang attribute: a tiny tag that matters more than you'd think
This is the lowest-effort fix in the entire audit, which is exactly why it earns a short post: a lot of sites still miss it, and it costs one attribute to get right.
The lang attribute declares what human language a page is written in. It sits on the opening <html> tag, and it quietly helps screen readers, search engines, browsers, and translation tools all do their jobs better.
What it looks like
<html lang="en">
That's it. en for English, es for Spanish, fr for French, and so on (ISO 639-1 codes). You can be more specific with a region (en-US, pt-BR) when it matters, but the base language code is the important part. Our check verifies the attribute is present and set.
Why such a small thing matters
Screen readers use it to pronounce your page. This is the big one. A screen reader switches its pronunciation rules and accent based on lang. Without it, an English page might get read with the wrong phonetics, or a screen reader set to another language will mangle your content. With it, the words sound right. For a user who works through a page by ear, that's the difference between usable and painful.
Search engines use it as a language signal. Engines do detect language from content, but an explicit declaration removes ambiguity and helps them serve your page to the right audience.
Browsers use it too, for offering translation, choosing the right fonts and hyphenation, and applying language-specific spell-check in form fields.
For one attribute, that's a lot of payoff.
Getting it right
- Set it on
<html>.<html lang="en">. Most templates have this in one place, so it's a single edit that covers the whole site. - Use the right code. Match the language your content is actually written in. Don't leave a template default of
enon a French site. - Mark exceptions inline. If a chunk of the page is in another language (a quote, a foreign phrase) you can wrap it:
<span lang="fr">c'est la vie</span>. Nice to have, not required. - Add a region only if it matters.
enis fine for most English sites; useen-GBvsen-USwhen spelling or locale genuinely differ.
How it relates to hreflang
These two get confused because both involve language. The difference is scope:
langdeclares the language of this one page, for browsers and assistive tech.- hreflang connects the multiple language versions of a page so search engines show the right one to the right user.
A single-language site needs lang and not hreflang. A multilingual site needs both: lang on each page to declare its language, and hreflang across pages to link the translations. They complement each other.
Common mistakes
- Missing the attribute entirely: the most common case, and the one we flag.
- A wrong default: a template shipping
lang="en"on a site that's actually in another language. - Over-specifying: using
en-USeverywhere when plainenis fine, then having to maintain it. - Forgetting inline switches: not strictly required, but nice for accessibility when you quote another language.
FAQ
What does the lang attribute actually do?
It tells browsers, screen readers, and search engines what language the page is in, which controls screen-reader pronunciation, translation offers, and language signals for search.
Is it required?
It's not enforced, but it's a baseline accessibility best practice and trivially easy. Missing it is a small, avoidable mark against your page.
What's the difference between lang and hreflang?
lang describes one page's language; hreflang links the different language versions of a page together for search engines. Single-language sites need only lang.
Do I need the region code, like en-US?
Usually not. Plain en is fine unless regional differences (spelling, locale) genuinely matter for your audience.
Key Takeaways
- The
langattribute belongs on the opening<html>tag and declares the page's language using an ISO 639-1 code, such as<html lang="en">. - Screen readers rely on
langto choose the correct pronunciation rules and accent; without it, an English page can be read with the wrong phonetics. langdescribes the language of a single page, while hreflang links the different language versions of a page together. A single-language site needs onlylang.- Plain language codes like
enare enough for most sites; add a region code such asen-GBoren-USonly when spelling or locale genuinely differ.
Want to confirm every page declares its language? Run a free audit. We check the lang attribute (among many others). More in the SEO explainers.


