Working together for standards The Web Standards Project


There’s a lot of misinformation about how, when and where to declare a language – or multiple languages – within HTML and XHTML documents. Fortunately, the GEO group at the W3C provides us with details as to how to do this. Here are some guidelines to help:

  • Always declare the default text processing language of the page, using the html tag, unless there are more than one primary languages.
  • Use the lang and/or xml:lang attributes around text to indicate any changes in language.
  • Do not use Content-Language to declare the default text processing language, and do not use language attributes to declare the primary language metadata.
  • Do not declare the language of a document in the body tag.
  • For HTML use the lang attribute only, for XHTML 1.0 served as text/html use the lang and xml:lang attributes, and for XHTML served as XML use the xml:lang attribute only.
  • If the text in attribute values and element content is in different languages, consider using a russian doll approach.
  • For documents with multiple primary languages, decide whether you want to declare a single text processing language in the html tag, or leave it undefined.

This BUZZ entry is also available in German.

Return to top

Post a Reply

Comments are closed.


All of the entries posted in WaSP Buzz express the opinions of their individual authors. They do not necessarily reflect the plans or positions of the Web Standards Project as a group.

This site is valid XHTML 1.0 Strict, CSS | Get Buzz via RSS or Atom | Colophon | Legal