Define multiple languages in html root element's lang attribute?

swd_fs picture swd_fs · Aug 28, 2012 · Viewed 42.9k times · Source

I want to determine more than one language for a document, because it's available in more than one language. If I use:

<meta http-equiv="content-language" content="en,de,fr" />

this is not W3C valid and the validator says I should define it in the root's lang attribute, but this attribute only supports one language:

<html lang="en">

works, but not

<html lang="de,en,fr">

So where should I define it?

Answer

jagb picture jagb · Jan 21, 2014

All attributes support only one language, so I believe you should define only one language; the most important language should be set. This can't be done if you have multiple languages on a single document, so here is the info to solve your problem:

The lang and xml:lang attributes do not allow you to assign multiple languages to a single document. So if you're writing a Web page with multiple languages you have two options:

  1. Define a primary language with the lang attribute, and then call out the secondary language(s) with lang attributes on elements in the document
  2. Define lang in the specific sections of the document as needed:

    <div lang="fr-CA" xml:lang="fr-CA">
    Canadian French content...
    </div>
    <div lang="en-CA" xml:lang="en-CA">
    Canadian English content...
    </div>
    <div lang="nl-NL" xml:lang="nl-NL">
    Netherlands, Dutch content...
    </div>
    

I have some multiple-language pages and I do use the 2nd option.

You might want to read http://www.w3.org/TR/2007/NOTE-i18n-html-tech-lang-20070412/#ri20060630.133619987