Re: Errors in CSS1, CSS2 specs (mainly css grammar)

Ian Hickson writes:
 > 
 > While pursuing the CSS specs I discovered some anomalies. They are listed below.

Thanks. I believe you are correct in all but two of them:

 > 
 > ================
 > 
 > Here is an extract from the CSS1 grammar [1]:
 > 
 > #    unicode         \\[0-9a-f]{1,4}
 > #    latin1          [¡-ÿ]
 > #    escape          {unicode}|\\[ -~¡-ÿ]
 > #    nmchar          [-a-z0-9]|{latin1}|{escape}
 > #    name            {nmchar}+       
 > #    "."{name}       {BEGIN(AFTER_IDENT); return CLASS;}
 > 
 > According to this, a number *is* allowed at the start of a class,
 > since a class consists of a "." followed by a {name} and a {name}
 > consists of one or more {nmchar} and {nmchar} is any of "-", "a"-"z",
 > "0"-"9", {latin1} or {escape}. This is not what CSS1 says at the end
 > of section 7.1 [2]:
 > 
 > #    * in CSS1, selectors (element names, classes and IDs) can contain
 > #      only the characters A-Z, 0-9, and Unicode characters 161-255, plus
 > #      dash (-); they cannot start with a dash or a digit; [...]
 >                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Indeed. This error in the grammar seems to haunt us, and this time
again we forgot to correct it :-( The intention is that class names
may not start with a digit, so the error is in the grammar.
Unfortunately, there are differences in implementation already. Some
implementers (understandably) missed the text in 7.1.

 > ================
 > 
 > CSS1, Appendix B, Paragraph 2 [1]: 
 > 
 > #   It is in some sense, however, still a superset of CSS1: there are
 > #   additional semantic constraints not expressed in this grammar.
 > 
 > The word "superset" should be "subset".

No, it should not. The grammar defines a language that is smaller than
the language defined in 7.1, but still larger than CSS1. For example,
appendix B allows 'font-size: bold', which is not a legal declaration
in CSS1.

 > 
 > ================
 > 
 > The CSS2 grammar [2] appears to be missing the line returning CLASS
 > altogether.

Correct, but this is not an error. CSS2 doesn't define "class" as a
terminal symbol, but instead as a non-terminal:

    class: '.' IDENT;

It is at a different level in the definition, but the effect is the
same (and this time the initial digit *is* forbidden :-) )

 > 
 > ================
 > 
 > The last paragraph of the CSS2 grammar says [3]:
 >  
 > #   In CSS1, a class name could start with a digit (".55ft"), unless it
 > #   was a dimension (".55in"). In CSS2, such classes are parsed as
 > #   unknown dimensions (to allow for future additions of new units). To
 > #   make ".55ft" a valid class, CSS2 requires the first digit to be
 > #   escaped (".\55ft")
 > 
 > The final string is incorrect. The correct way of escaping ".55ft" so
 > that it is a valid CSS2 class is ".\abc 5ft", where "\abc" is whatever
 > the unicode id for the number "5" is in hexidecimal.

In fact, the whole paragraph might have been omitted. CSS1 only
*appeared* to allow initial digits, but as you pointed out, the text
in 7.1 explicitly forbade them.

I don't know how we could have missed the escape. It should indeed be
".\35 5ft".

 > 
 > ================
 > 
 > The CSS2 errata [4] document has a typo too (!):
 > 
 > # Section 9.2.1
 > #
 > #  In the example after the diagram, the HTML fragment "<P>jThis is the
 > #  content of P.</>" should end instead with the end tag "</P>".
 > 
 > There is a extraneous "j" after the "<P>", which does not appear in
 > the CSS2 spec.

OK.

 > 
 > ================
 > 
 > References:
 > [1] http://www.w3.org/TR/REC-CSS1#appendix-b
 > [2] http://www.w3.org/TR/REC-CSS1#forward-compatible-parsing
 > [3] http://www.w3.org/TR/REC-CSS2/grammar.html
 > [4] http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata.html
 > 
 > -- 
 > Ian Hickson
 > 
 > 

Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Monday, 11 January 1999 08:08:52 UTC