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

Re: Forget what I said about whitespace

From: Bert Bos <bert@w3.org>
Date: Wed, 17 Dec 1997 11:47:54 +0100
To: www-style@w3.org
Message-ID: <3497ADDA.40041A6C@w3.org>
Neil St.Laurent wrote:
> 
> Both IE and Netscape implement whitespace stripping and token
> matching incorrectly in CSS, thus I'm sure that it will become part
> of the standard:

I think you misread the specification. As far as I can see, both
browsers follow the CSS1 specification quite well.

> 
> Consider:
> 
> background:repeaturl(image.gif);
> 
> That, according to the core grammar and property rules is perfectly
> valid in CSS and implies that the background image "image.gif" is
> repeated in all directions.

No, this is not valid CSS1. According to the tokenization rules in CSS1,
this parses as:

   1. IDENT ("background")
   2. ':'
   3. IDENT ("repeaturl")
   4. *illegal character* ("(")
   5. IDENT ("image")
   6. CLASS_AFTER_IDENT (".gif")
   7. *illegal character* (")")
   8. ';'

So if you, as a CSS1 parser, encounter this, and you know who wrote it,
please notify the author that there probably is an error in his style
sheet, somewhere near "repeaturl".

> But alas, neither explorer nor netscape recognize this... meaning
> that for compatiblity with existing browsers we cannot strip any
> space at all from the files -- we'll still recognize the above, but
> will have to put space back in afterwards.

Please don't! We will get backward compatibility problems later.

What will you do if there is a keyword that is a prefix of another: say
we add "greenish", will you parse that as "green" + "ish"? Or a more
practical example: it is likely that we will have a pseudo-class
":first" in CSS2, will that cause your parser to forget about the
pseudo-elements ":first-letter" and ":first-line"?

> All these problems because space was used as a token!

We are aware that the significance of whitespace in the selectors makes
parsing slightly harder, but there is nothing special about spaces on
the right hand side. Like in most other languages, a token is always as
long as possible. Thus "repeaturl" is only one identifier, and not two
(or three, or four, or...)

That does indeed mean that you may have to put in some spaces when you
write out a style sheet. Butwhatismorenaturalthanthat?


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 93 65 76 92            06902 Sophia Antipolis Cedex, France
  +33 (0)4 92 38 76 92 (<--- after 5 Jan 1998)
Received on Wednesday, 17 December 1997 05:48:19 GMT

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