W3C International Internationalization / Localization

This page is no longer maintained and may be inaccurate. For more up-to-date information, see the Internationalization Activity home page.

Putting language attributes in HTML

It's a good idea to label documents with the language they are written in. Some browsers don't care, but more advanced browsers, and especially editors with spelling checkers, can use the information. It is also expected that more and more other Web applications will be able to use the information, including search engines that will search for documents in a particular language.

  1. The first step in labeling a document is to get the server to label it. (Ideally, labeling the document (step 2) should be enough: the server will look at what the document says about itself - but not many servers do that yet.)
  2. Put a line like the following in the HEAD of the document:
    <META HTTP-EQUIV=Content-Language CONTENT=en>

    Replace `en' with the proper language: en (=english), fr (=french), de (=german), etc. (See also `Language tags and attributes' and ISO-639.)

  3. If parts of the document are in a different language, put a label on the elements concerned. For example, to mark that a certain quote is in French:
    <P>... And here is a quote from president Chirac:
    <BLOCKQUOTE lang=fr>
    <P>Rien n'est facile, mais nous devons choisir
    la bonne voie, celle qui concilie la
    justice, la solidarité et la modernité.

    (It is not necessary to repeat the attribute on all the elements inside the labeled one, they will automatically be in French as well.)

Pointing to translated documents

For the new HTML (code name `Cougar') a simple scheme is proposed that allows you to add links to translations (or just to related documents in other languages) in the HEAD of your document. More advanced schemes are under study as well, but they will mostly be useful for people managing large collections of documents.

The simple scheme works like this. Imagine you've written an article called `Underground life' and you had it translated into French and German. You can then add this to the HEAD of your document:

<LINK REL=alternate HREF=mydoc-fr.html LANG=fr
  TITLE="La vie souterrainne">
<LINK REL=alternate HREF=mydoc-de.html LANG=de TITLE="Leben unter Grund">

This adds two links to your document, one to a French (LANG=fr) document and one to a German (LANG=de) one. The REL=alternate means they are equivalent documents to the current one, but in some alternative form, in this case in a different language.

W3C Bert Bos, i18n coordinator
Last updated 29 Apr 1997