Not coming to grips with the CSS syntax

So I'm still trying to come to grips with CSS syntax.

Etan Wexler [1] made me aware of the fact that there is defined a general
CSS core syntax which a parser can rely on. This is said to be valid for
any levels of CSS, and it is defined in [2].

But then, section 4.1.1 "Tokenization" says: "The list of tokens for CSS
2.1 is as follows." So it seems that what is about to be described is no
longer a general syntax, but only valid for CSS21. This looks
inconsistent with the introductory wording and suggests a different
tokenization may be defined for any level of CSS.

Assuming section 4.1.1 describes the general syntax of CSS21 only, it
promptly is scrapped in 4.1.3 "Characters and case" by specifically
introducing restrictions on the tokenization level by e.g. not allowing a
leading hyphen on the FUNCTION token (resp. its {ident} constituent).

At the end of section 4.1.1 "Tokenization" it says:

"The meaning of input that cannot be tokenized or parsed is undefined in
CSS 2.1."

However, CSS21 actually _does_ define the meaning of some input that
cannot be parsed according to the defined core syntax, namely in 4.2,
Rules for handling parsing errors, item "Malformed declarations". All
error examples would not parse according to the core syntax (->"handling
is undefined"), yet needs to be handled in some defined way.

I then turned to the css3-syntax [3]. There, I e.g. find no longer the
restriction on the FUNCTION token not being allowed to start with a
hyphen, which leads to a problem with unary minus I described earlier
here [4]. This means that in the present state, one would need two
different and incompatible tokenizers: one for CSS21, one for CSS3. (I'm
not going into the associated problem of detecting which one to use for a
stylesheet at hand, lacking versioning info in the stylesheet itself.)

I'm looking for any comments helping me to understand the intent of the
spec, and what exactly a conforming parser is expected to do.

[1] <http://www.w3.org/mid/F4B33E00-281A-11D9-9C63-000502CB1B77@stickdog.com>
[2] <http://www.w3.org/TR/CSS21/syndata.html#syntax>
[3] <http://www.w3.org/TR/2003/WD-css3-syntax-20030813/#syntax>
[4] <http://lists.w3.org/Archives/Public/www-style/2004Oct/0075.html>
(though it seems that my concern is only valid in the context of CSS3)

Regards, Christian.

Received on Thursday, 4 November 2004 12:03:01 UTC