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.
- Previous post: CSS Table Gallery
- Next post: Ten favourite Mac applications


Comments
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) :)
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…
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.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?
They recommend using both
langandxml:langfor XHTML 1.0 served astext/html. That’s silly, since that is just bad HTML, and there is noxml:langattribute in HTML.These rules as old as Adam. But useful.
Comments are disabled for this post, but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.