« Web spotting roundup: the WASP lead edition | Main | Tokyo hosts SVG Open 2007 »

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
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 lang attribute has been removed in favor of the xml:lang attribute (as defined in [XHTMLMOD])."
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.
editor draft
lang text/html The lang attribute may only be used on elements of HTML documents. Authors must not use the lang attribute in XML documents.
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 xml:lang attribute may only be used on elements of XML documents. Authors must not use the xml:lang attribute in HTML documents.

Filed by Karl Dubost on August 28, 2007 6:40 AM in HTML, Reference
| | Comments (5) | TrackBacks (0)


Richard Ishida # 2007-08-28

"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.

Karl Dubost Author Profile Page # 2007-08-28

@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.

Anne van Kesteren # 2007-09-02

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.)

hemal shah # 2007-09-10

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?

Dom # 2009-03-06

Note that there are now ongoing and promising discussions on bringing the lang attribute to all versions of XHTML.

Leave a comment

Note: this blog is intended to foster polite on-topic discussions. Comments failing these requirements and spam will not get published. Please, enter your real name and email address. Every individual comment is reviewed by the W3C staff. This may take some time, thank you for your patience.

You can use the following HTML markup (a href, b, i, br/, p, strong, em, ul, ol, li, blockquote, pre) and/or Markdown syntax.

Your comment

About you

This blog is written by W3C staff and working group participants,
 and maintained by Coralie Mercier.
Authorized parties may log in to create a new entry.
Powered by Movable Type, magpierss and a lot of Web Technology