- From: Bert Bos <bert@w3.org>
- Date: Tue, 7 Dec 1999 21:22:07 +0100 (MET)
- To: www-style <www-style@w3.org>
Matthew Brealey writes:
> --- Sjoerd Visscher <sjoerd@heeten.nl> wrote:
> > Hi all,
> >
> > I am using CSS more and more lately, and I notice
> > that I need the following
> > pattern very often:
> >
> > A B {...}
> > A C {...}
> > A D {...}
> >
> > I use this f.e. when I have a table that needs to
> > jump out of the rest of
> > the page, and the <TR>,<TD>,<TH> and often also <A>
> > need to be differnt for
> > this case. I do not want to add a class to all these
> > elements, so I only add
> > a class to the table, which results in the following
> > css:
> >
> > TABLE.special TR {...}
> > TABLE.special TH {...}
> > TABLE.special TD {...}
> > TABLE.special A {...}
> >
> > This is not only clumsy and ugly, it is also very
> > slow. (As was demonstrated
> > by similar cases in the UI of Mozilla)
> >
> > To solve this I'd like to introduce the following:
> >
> > @has-ancestor TABLE.special {
> > TR {...}
> > TH {...}
> > TD {...}
> > A {...}
> > }
> >
> > This makes the rule matching much faster, because a
> > UA only has to look for
> > matches in the subtree of TABLE.special elements.
> >
> > If anyone has a better solution (especially when
> > it's done with CSS2) please
> > let me know.
>
> Apart, obviously from TABLE.special *, there is none,
> and neither should there be IMHO.
>
> CSS extensions should be limited to those that allow
> us to do what we couldn't do using CSS before, so IMO
> this is barely an improvement, since it would be
> almost as quick to have
> > TABLE.special TR {...}
> > TABLE.special TH {...}
> > TABLE.special TD {...}
> > TABLE.special A {...}
> than have to bother with an @ rule as well.
I agree. Maybe the @rule saves a few keystrokes, but I doubt if it is
actually any easier to read (or type). I think adding a comment or
laying out the style sheet carefully is just as good.
In my experience, style sheets aren't long and complex enough to need
any internal structuring.
A little bit of redundancy is not a problem. I suspect that if you
include the time you spend thinking about what to put after the @-rule
and how many {}-pairs you need, you can actually type the 4 or 5
repeated selectors quicker.
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 Tuesday, 7 December 1999 22:41:04 UTC