HTML Lang: Set the Correct Language for SEO and Accessibility
The lang attribute on the <html> element declares the primary language of a page.
It helps browsers, search engines, translation tools, and assistive technologies interpret content correctly.
What Is HTML Lang?
<html lang="en">
For regional variants, use language-region format:
<html lang="en-US">
Why It Matters
HTML language declaration supports:
- Accessibility: screen readers choose pronunciation and language rules.
- International SEO signals: search engines better understand language targeting.
- Browser behavior: spell check, translation prompts, and typography can improve.
Best Practices
1. Always set lang on the root <html> tag
Every page should include it.
2. Use valid language codes
Prefer BCP 47 style values like en, en-US, sk, de, fr-CA.
3. Match the dominant page language
Use the language users actually read on that page.
4. Keep it consistent with localized page variants
If you have translated versions, ensure each version sets its own correct lang value.
Common Mistakes
- Omitting the
langattribute entirely. - Using invalid or custom codes.
- Setting
langto English on non-English content. - Leaving stale values after localization changes.
Good vs Bad Examples
Good
<html lang="en">
Good (region-specific)
<html lang="en-GB">
Bad
<html>
No language declared.
Bad
<html lang="english">
Not a valid standard language code.
Quick Checklist
Before launch, verify:
- The root
<html>has alangattribute. - Language code uses valid format (
en,en-US, etc.). - Code reflects actual page language.
- Localized pages use their own correct language tags.
Final Takeaway
lang is a small attribute with important impact. It improves accessibility and helps search engines and browsers process your content correctly.