lang attributes accross (X)HTML versions
There has been a discussion about lang
attributes on the RDFa mailing-list, on what should be used depending on the HTML version. So I have done a bit or research and compilation and here are the results.
The lang attribute
W3C Internationalization has created a full tutorial on declaring language in XHTML and HTML.As the tutorial says that information about the language in use on a page is important for accessibility, styling, searching.
. You can also read Using attributes to declare language.
lang attributes in specifications
version | syntaxe | content-type | comment |
---|---|---|---|
html 4.01 | lang | text/html | There are specific rules for lang inheritance of tables. |
xhtml 1.0 | lang xml:lang |
text/html application/xhtml+xml |
xhtml 1.0 is using the definition given in the HTML 4.01 specification. The issue is that the specification gives the possibility to serve the same document with two different content-types. When there is a conflict between xml:lang and lang values, xml:lang takes precedence even served as text/html . |
xhtml 1.1 | xml:lang | application/xhtml+xml | The semantics of xhtml 1.1 is defined in html 4.01 but "On every element, the |
xhtml 2.0 working draft |
xml:lang | application/xhtml+xml | xhtml 2.0 follows the rules defined in XML for the xml:lang attribute. There are no specific rules defined for tables. By the user agent conformance rules, lang attributes must be ignored. |
html5/html editor draft |
lang | text/html | The |
html5/xml editor draft |
xml:lang | application/xhtml+xml | html5/xml follows the rules defined in XML for the xml:lang attribute.The editor document says that The |
"When there is a conflict between xml:lang and lang values, xml:lang takes precedence even served as text/html."
Well, that's the theory, but as far as I'm aware from testing it is not at all the practice. This may not be clear to some people, and may cause some confusion when they read this post.
@Richard: This is an interesting information. Do you have a link to an implementation report for the products which behave as such and those which don't and in which circumstances. I'm pretty sure it would be helpful for the community and the HTML WG.
It's only the case when xml:lang is inserted through the DOM. The attribute as such can't be written in a text/html document as text/html doesn't do namespaces. (You can test this all fairly trivially using the :lang selector.)
Hi there, i was not able to read this page (comments section) properly in IE7. So out of doubt, i checked this page for its validity... this page is not valid and has four errors. but primarly, can some one look why it does not show properly in IE7?
Note that there are now ongoing and promising discussions on bringing the lang attribute to all versions of XHTML.