Declaring Languages in HTML and XHTML

There is a good summary of techniques for specifying the language of content at The Web Standards Project: Best Practices for Declaring Languages in HTML and XHTML.

Developers who never come in contact with other languages than English may not have much need for this, but for the rest of us a summary like this is very helpful.

I’d like to add one more guideline: Do not specify the language of a document in the DOCTYPE declaration. I have seen people do that too often. The language code in the DOCTYPE declaration declares the language of the document type definition that the DOCTYPE URI points to. For the W3C DTDs, that language is always English, so don’t go changing that //EN.

Posted on September 11, 2005 in (X)HTML, Quicklinks

Blog reactions: Other blogs commenting on this post

Comments

1. September 11, 2005 by Patrick

Have a look at http://dn.se - they have the attributes where they should be, but have mixed up the definition of Swedish; it should be sv-SE but they've chosen se-SV which makes DN by far the largest (and only) newspaper on the web in Northern Sami (El Salvador) :)

2. September 11, 2005 by Patrick

Oh, and I've e-mailed them a couple of days ago about correcting it but either they're swamped with other bugs related to the re-design of the web site or they have no clue that they've got the lang-codes wrong...

3. September 11, 2005 by Roger Johansson

Patrick: They should clean up their markup and inject a bit of semantics while they're at it. Headings? Paragraphs? No, lets use <span class="h1"> and <span class="text"> instead.

4. September 11, 2005 by Patrick

That's actually really bad - I just glanced through the code to see if they finally had got rid of the last traces of table-based design elements, which they of course had't. I wonder who's responsible for the design, maybe they need someone who knows web standards and semantic design?

5. September 12, 2005 by Tommy Olsson

They recommend using both lang and xml:lang for XHTML 1.0 served as text/html. That's silly, since that is just bad HTML, and there is no xml:lang attribute in HTML.

6. September 13, 2005 by Maksim Rossomachin

These rules as old as Adam. But useful.

Sorry, comments are closed for this post.

Search and sponsorship

Job opportunities

Authentic Jobs: Come in, we're hiring

Job openings from Authentic Jobs

Looking for web hosting?

Try DreamHost!

Use the promo code 456BEREASTREET3 to save USD 20 when you sign up for DreamHost