Re: IDs *not* in selectors

Sue Sims writes:
 > >> selectors 
 > >Both are perfectly legal CSS, as Peter explained.  
 > Appendix D is not written in my native language, and I admit to a
 > problem understanding it, even when 'optimized for human consumption'.
 > >However, such
 > >selectors cannot match anything in a legal HTML document, since ID
 > >attributes in HTML must begin with a letter [1].  However, since HTML
 > >does not define error-handling rules, I think it's really up to the
 > >user-agent whether to allow this or not.
 > When HTML has a normative definition for ID and name tokens (1), why
 > would CSS deliberately introduce this conflict with that definition? I'd
 > also posit that UAs decision(s) on whether to 'allow' this might well be
 > divergent, thereby introducing yet another layer^Wstratum of confusion
 > amongst authors. This issue has been discussed previously, and I'd
 > thought it was settled. (2)

CSS sometimes allows things that cannot occur in HTML or XML, E.g.,
"#\20" (an ID selector consisting of a space) is legal in CSS, but
cannot match anything in HTML or XML. The reason CSS does this is
because you never know what HTML or XML or their successors may allow
in the future.

But about the digits at the start the spec indeed contradicts itself.
People that read the grammar will reach a different conclusion than
people that read the text. The spec should be fixed.

Since CSS1 allowed digits, I think we should change the text in 4.1.3
to match the grammar (i.e., digits are allowed), rather than

(That's the opposite conclusion from (2), where the spec also
contradicted itself, but in contrast to ID selectors, class names
cannot be made to start with digits because that would cause
ambiguities: is ".12mile" a dimension or a class?)

It doesn't matter for people writing style sheets: whether the browser
allows "#123myid" or skips it, it will never match anything in XML or
HTML anyway. But it does matter for people writing scripts using the
DOM: "#123myid" either is a rule that you can change so that it
matches something, or it is garbage that has been skipped by the
parser and doesn't appear in the DOM at all.

 > [1]
 > (2)

  Bert Bos                                ( W 3 C )                              W3C/INRIA                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Friday, 9 July 1999 08:06:12 UTC