views:

473

answers:

2

I've got an XHTML 1.0 Transitional document. Most of the content is in English, hence this is what I've got at the top:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

Some elements are in different languages, e.g.

<a href="#" lang="es">Español</a>

Do I need to add xml:lang="es" to elements like these as well, thus duplicating the language information?

+1  A: 

According to the XHTML 1.0 spec: yes, use both.

Doesn't say why though.

Dive Into Accessibility's language page says the same thing, as mentioned in Rahul's answer to a similar question.

Paul D. Waite
+1 Good question, good answer.
Andrew Hare
Aw, thank you! Tiny thing, but it was bothering me.
Paul D. Waite
+2  A: 

If you're sending the file with the text/html MIME type, you should, because you're trying to use both HTML and XHTML. (Browsers will only look at the lang, though.)

If you're using the correct MIME type (application/xhtml+xml), on the other hand, only xml:lang="" is necessary, if (correctly) pointing out that you're using HTML, with an HTML doctype, you just need lang="".

Ms2ger
Thanks man, I think that makes sense. So the idea is that if the document is parsed by a parser that only understands XML (or at least doesn’t know about the particular semantics of XHTML), it still knows that that element is in Spanish.
Paul D. Waite