Hide and Seek

Language and encoding

language · Readability · weight 10 of 120

What we check

On your home page and each sampled page, we check two things, each worth half:

  • The <html> element has a lang attribute with a well-formed language tag, like en or en-US. (en_US, with an underscore, isn’t one.)
  • The character encoding is declared, with a <meta charset> tag or in the server’s response headers.

If there’s a language tag, we also check it against the text with a simple test that recognizes English, Spanish, French, German, Portuguese, Italian, and Dutch. If the text is clearly in a different language from the tag — lang="ja" on a page of English, say — that’s reported and the language half is lost. Text too short or too mixed to tell isn’t judged. The score is the worst page’s.

Why it matters

An assistant uses the language to decide who your page is for and how to read it. A wrong tag, often left over from a template, can mean your page is treated as being in another language and passed over when someone asks in yours.

Without a declared encoding, a bot has to guess, and a wrong guess turns curly quotes and accented letters into garbage.

How to pass

  1. Set the language on the <html> element, matching what the page is actually written in.
  2. Declare the encoding as the first thing in the head:
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      …
  3. If you publish in more than one language, set lang per page, not once for the whole site.

Back to the rules