W3C home > Mailing lists > Public > www-style@w3.org > January 2008

Re: Clustering

From: Bert Bos <bert@w3.org>
Date: Thu, 17 Jan 2008 16:00:08 +0100
To: CSS Style <www-style@w3.org>
Message-Id: <200801171600.08395.bert@w3.org>

On Thursday 17 January 2008 11:31, Philip TAYLOR wrote:
> Although I write CSS on a more-or-less daily basis,
> I still regularly find myself using an incorrect syntax
> that seems so natural to me that I simply fail to remember
> that it is incorrect.  Time and again I find myself
> writing defective CSS such as
>
> 	Foo.bar {margin-top, margin-bottom: 1ex}
>
> only to belatedly remember that I am required to
> either explicitly replicate the value, as in
>
> 	Foo.bar {margin-top: 1ex; margin-bottom: 1ex}
>
> or (far worse) use the totally unmemorable shorthand
>
> 	Foo.bar {margin: ...}

Tastes differ, I guess :-) I often go out of my way to write the rules 
such that I can use 'margin' instead of the individual properties.

>
> where I invariably forget the order of the (upto) four values.
>
> Given CSS allows me to cluster selectors, as in
>
> 	Foo.bar, Foo.baz {property: value; ...}
>
> is there any fundamental reason why it could not
> be extended to allow /properties/ to be clustered
> in the same way ?

It's not foreseen in the grammar of CSS. That grammar calls it a 
malformed declaration. It's true that the error recovery rules will 
cause the parser to synchronize again at the next semicolon, but it is 
an error, not something reserved for future use, such as an unknown 
property.

Another argument against this notation is that it is in fact quite rare 
to have two properties with the same value in the same rule set. It can 
happen for margins, padding, maybe border color and color, but that's 
about it. And precisely for those cases there are shorthands already.

Maybe we need the shorthands 'margin-left-right' 
and 'margin-top-bottom'. Those would fit in the grammar. On the other 
hand, having too many shorthands slows the author down, instead of 
helping him. One shorthand seems easier to (learn to) use than several, 
see, e.g., the many border shorthands.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Thursday, 17 January 2008 15:00:20 GMT

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