How to Set the Language Attribute on Your Website
A single missing attribute can make screen readers mispronounce your whole site. Here is the two-minute fix that tells browsers what language your pages are in.
Reviewed by Jacob Rhinehart for Strelva's co-founder; products and operations lead responsibilities.
This is one of the fastest accessibility fixes there is, and one of the most overlooked. The lang attribute on your page's <html> tag tells browsers and assistive technology what language the content is in. Leave it off and a screen reader may apply the wrong pronunciation rules, reading your English text with, say, French phonetics. It is jarring and hard to follow.
Why it matters
Beyond pronunciation, the language attribute affects browser spell-check, automatic translation prompts, and proper hyphenation. It is a small signal with a wide reach, and WCAG requires it.
Step by step
- Check the current value. View your page source and look at the opening <html> tag. You want something like <html lang="en">. Note if it is missing, empty, or wrong.
- Add the right code. Set lang to your primary language: en for English, es for Spanish, fr for French, and so on. Use a valid code, not a word like "english."
- Handle mixed-language content. If a section is in another language, add a lang attribute to that section while the page-level lang stays on your main language.
- Verify across pages. This is set once in your template and applies everywhere, so checking two or three pages confirms the whole site.
Set and forget
Because it lives in the shared template, you fix this once and never think about it again. Few accessibility wins are this cheap.
Frequently asked
What business owners ask next.
What value should I use for English?
Use lang="en" for English generally, or a regional variant like lang="en-US" or lang="en-GB" if you want to be specific. Use valid language codes, never a spelled-out word like "english."
Do I have to add this to every page?
No. It lives in your shared HTML template, so setting it once applies it site-wide. Just confirm it appears in the source on a couple of pages.
My site is bilingual. How do I handle that?
Set the html tag to your primary language, then add a lang attribute to any block of content written in the other language. That way each section is announced correctly.