Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathantneal/9309367 to your computer and use it in GitHub Desktop.
Save jonathantneal/9309367 to your computer and use it in GitHub Desktop.
What’s in a language?

What’s in a language?

TL;DR

English is the default language of the web.

If you serve multilingual content, you should know about the Content-Language header and the lang attribute.

The Content-Language header describes the language understood by your audience. It may contain multiple languages, but in practice, you should keep individual pages monolingual.

The lang attribute describes the language of actual content.

While these are not synonymous declarations, the lang attribute will fall back to the Content-Language header.

A little deeper

The Content-Language header describes the language of the intended audience for an entire page. This means a page written in English for English readers might use Content-Language: en. This also means a page intending to teach French to English readers might use Content-Language: en, even though the page contains French.

The lang attribute describes the actual language of a page or section. This means a page written in English for English readers might use lang="en" on the <html> element. However, a page intending to teach French to English readers might use lang="en" with <html>; or the sections written in English and French might use lang="en" and lang="fr" respectively.

In practice

The Content-Language header is sufficient to describe monolingual pages, and is not required for English pages. Similarly, if your page has content that is mostly not English, use a lang attribute on <html> to declare the default language.

Google Search will determine the language of a page by the Content-Language header and the actual content of the page, ignoring the lang attribute. If you’re working on a multilingual site, stick to one language per page, and avoid side-by-side translations. Finally, avoid automatic redirections based on the user's perceived language. Instead, cross-link differing languages page by page.

Further reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment