SEO essentials · 2 checks

Page language and character set check

Check the lang attribute on your page and that the character set declared by the server and in the HTML agree.

Check your page

Included in the free scan of 85 SEO and GEO checks.

What this checks

The lang attribute tells browsers, screen readers and translation tools which language the page is in. The character set tells the browser how to turn bytes into letters; when it is wrong, accented letters turn into garbled symbols.

Google detects a page’s language from its visible content rather than from the lang attribute, so this check is mostly about readers and tools.

The 2 checks on this page

Each check has its own result in your report. “Learn more” in the report opens the matching card here.

PAGE-007

HTML language declaration

Reads lang on the html element and checks that it is a real language code (ISO 639, two or three letters, with an optional region).

  • Pass A valid language code
  • Suggestion No lang attribute
  • Problem An invalid value such as “english”
PAGE-009

Character encoding declarations

When the HTTP header and the HTML both declare a charset, checks that they name the same encoding.

  • Pass Consistent
  • Problem Different encodings
  • Not measured An unrecognized charset name

Examples

Passes: Language and charset declared
<html lang="es-MX">
<head><meta charset="utf-8">
Flagged: Header and page disagree
Content-Type: text/html; charset=iso-8859-1
<meta charset="utf-8">

How to fix it

WordPress

Set the site language under Settings › General; the theme prints it in the html tag.

Next.js

Set lang on the html element in the root layout, per locale if the site is multilingual.

Nginx / Apache

Send charset=utf-8 in Content-Type, or omit it, and keep <meta charset="utf-8"> as the first element in head.

Check your fix

  1. View source and read the html tag and the first lines of head.
  2. Run curl -I and check the Content-Type header.

Questions

Does lang affect Google rankings?

Google says it detects language from visible content. lang still matters for screen readers and translation.

en-UK or en-GB?

en-GB. The region code for the United Kingdom is GB.

Sources

Related