Last updated on 30 Agustus 2010 by Dani Iswara
Pure (X)HTML documents served as
application/xhtml+xml are not fully usable nor accessible. Especially for old and nonstandard user agents/Web browsers and assistive technology. The problem is
lang (language) attribute.
Language attribute has semantic meaning. You may check my old posts (most of them are in bahasa Indonesia) in Dani Iswara .com:
- Penulisan Elemen
- Semantik 'bold' dan 'italic' untuk Pelokalan Bahasa.
- Latah Memakai Deklarasi XML.
Foreign languages texts/content should be marked-up using, such as:
xml-lang="id"("id" refer to Indonesian) if a document is served as pure XML.
lang="id"if a document is served as
Doctype switching and language attribute
One document may serve as bilingual with the help of
lang declaration in doctype. The other solution is using
lang attribute in the content itself, especially for terms in foreign languages.
There is a well-known technique called doctype switching or server negotiation. Similar to mobile version detection of Web pages. In server level, Web pages may sent as
application/xhtml+xml to the capable user agents, and as
text/html to the other and old user agents (e.g. Internet Explorer).
But, doctype switching is not working as easy as it could be for bilingual documents. The reason is, it is impossible to use
lang="id" in the same time for different languages in different type of documents. This markup,
xml-lang="id", can be suitable for modern user agents with XML rendering capability. But not for old user agents.
Bilingual content using doctype switching is not usable for Web authors and not accessible for aural agent users. Better to have a different page version of bilingual content. Or stick with one language or one content type. If using only one content type,
xml-lang attribute can be used properly.