W3C home > Mailing lists > Public > www-style@w3.org > December 2002

Re: CSS parser recovery

From: Tantek Çelik <tantek@cs.stanford.edu>
Date: Sat, 14 Dec 2002 01:39:51 -0800
To: Ian Hickson <ian@hixie.ch>
CC: "www-style@w3.org" <www-style@w3.org>
Message-ID: <BA203C67.1BB10%tantek@cs.stanford.edu>

On 12/13/02 11:17 PM, "Ian Hickson" <ian@hixie.ch> wrote:

> 
> On Fri, 13 Dec 2002, Tantek Çelik wrote:
>> 
>> It is a misconception that you must match random braces everywhere when
>> parsing CSS.  See CSS1 section 7.1 for precise specifics on when "blocks"
>> (as defined in 7.1, {...} ) may appear.
> 
> CSS1 7.1 (emphasis mine):
> 
> # A block starts with a left curly brace ({) and ends with the
> # matching right curly brace (}). In between there may be any
> # characters, except that parentheses (()), brackets ([]) and braces
> # ({}) always occur in matching pairs and may be nested. Single (')
> # and double quotes (") also occur in matching pairs, and characters
> # between them are parsed as a string (see the tokenizer in appendix B
> # for a definition of string).
> #
> # ...
> #
> # A declaration-block starts with a left curly brace ({) and ends with
> # the MATCHING right curly brace (}).
> 
> The spec doesn't explicitly give an example with a block before a
> colon, but I see no justification in the spec for ignoring the rules
> given above on the left hand side of a declaration.

It is very simple, the spec simply provides no allowance for a block on the
property side of the colon.


CSS 7.1:

<blockquote>
A declaration consists of a property, a colon (:) and a value.
</blockquote>

Note - no allowance for a block in the property, or after the property
before the colon.

Continued...

<blockquote>
Around each of these there may be whitespace.
</blockquote>

Explicit allowance of whitespace, but NO allowance of a block.

Continued...

<blockquote>
A property is an identifier, as defined earlier.
</blockquote>

And identifiers as defined earlier CANNOT contain blocks.

Continued...

<blockquote>
Any character may occur in the value, but parentheses (()), brackets ([]),
braces ({}), single quotes (') and double quotes (") must come in matching
pairs.
</blockquote>

Aha! Explicit allowance for a block in the value, and only the value portion
of the declaration.


Conclusion: 

The spec allows for (nested) block(s) after an @rule, a selector, and in a
value and nowhere else.


Tantek
Received on Saturday, 14 December 2002 04:25:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:17 GMT