Warning SEO

Missing lang Attribute on <html> — Essential for Accessibility and SEO

The lang attribute helps search engines and screen readers understand the page language.

What is the lang attribute?

The lang attribute on the <html> tag declares the primary language of the page content. It tells browsers, search engines, and assistive technologies what language the text is in.

Why is it critical?

Accessibility (WCAG requirement)

  • Screen readers use the lang attribute to select the correct pronunciation rules
  • Without it, a screen reader might try to read Spanish text with English pronunciation — making it incomprehensible
  • It's a Level A WCAG requirement — the most basic level of accessibility compliance

SEO

  • Search engines use it to understand the content language and serve it to the right audience
  • It's a signal for international SEO and geo-targeting
  • Helps with proper indexing in language-specific search results

Browser features

  • Browsers use it for spell checking in the correct language
  • Translation prompts — Browsers suggest translating pages when the lang doesn't match the user's language
  • Hyphenation and text rendering — Some languages require different text handling

How to fix it

Add the lang attribute to your <html> tag:

<html lang="en">

Common language codes

Code Language
en English
es Spanish
fr French
de German
pt Portuguese
ja Japanese
zh Chinese
ar Arabic
ko Korean
it Italian

For regional variants

<html lang="en-US">  <!-- American English -->
<html lang="en-GB">  <!-- British English -->
<html lang="pt-BR">  <!-- Brazilian Portuguese -->
<html lang="zh-CN">  <!-- Simplified Chinese -->

Best practices

  1. Always include it — Every HTML page should have a lang attribute
  2. Use the correct code — ISO 639-1 two-letter codes
  3. Match your content — Set the language of the majority of the page content
  4. Use lang on sub-elements — For mixed-language content: <span lang="fr">Bonjour</span>

Related articles