value for class attribute should be CDATA (not NMTOKENS)

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

value for class attribute should be CDATA (not NMTOKENS)

Michael[tm] Smith
A document containing an element which has a class attribute with
an empty value (for example, <div class="">) is valid in XHTML 1.0
(and in HTML 4.01), but it seems like the XHTML 1.1 specification
redefines the value of the class attribute in such a way that it's
no longer valid in XHTML 1.1

For the record, here are the details:

In the XHTML Common Attribute Definitions section[1] of the XHTML
Modularization 1.1 specification, the value of the class attribute
is defined as NMTOKENS:


But in the XHTML 1.0 DTDs (and in HTML 4.01), the value of the
class attribute is defined[2] as CDATA:


This seems to be a substantive change, but it's not documented in
the Changes from XHTML 1.0 Strict section[3] of the XHTML 1.1
specification, -- and
I've not so far been able to find any record of an announcement
about that change (nor any record of discussion about it at all).

Anyway, I note that the XML spec defines NMTOKENS as a space-
separated list of one or more NMTOKEN, and each NMTOKEN must be
one or more name characters,

  Nmtokens ::=  Nmtoken (#x20 Nmtoken)*
  Nmtoken  ::=  (NameChar)+

So as far as I can see from that, any attribute whose value is
defined as NMTOKENS must not be empty. So by redefining the value
of the class attribute from CDATA to NMTOKENS, the XHTML 1.1
specification introduces a change that's not backward compatible
with existing XHTML 1.0 content -- a change that'll cause users to
find that their existing XHTML 1.0-valid documents containing
empty class attributes are no longer considered valid in XHTML 1.1


Michael(tm) Smith