Re: @version rule

In message <Pine.WNT.4.31.0107301305420.1044-100000@HIXIE.netscape.com>, 
Ian Hickson <ian@hixie.ch> writes
>On Fri, 27 Jul 2001, George Lund wrote:
>>
>> What is needed is a mechanism for grouping CSS rules, such that either
>> they are all rules in the group are applied or none are.
>
>How would this work?
>
>Given:
>
>   @locked-together {
>      p * { color: green; }
>      div { background: white; }
>   }
>
>   em { color: blue; }

This is slightly bogus example because background and foreground colours 
should always be specified together.  (My use of the word bogus here is 
not at all intended to be rude, in case I need to clarify.)  Personally 
I think this is a rule that should actually be codified into the next 
version of CSS, but regardless of its technical status it should never 
be ignored.

I think the issue is perhaps that determining whether a set of rules has 
succeeded is potentially complex and would need discussion.

I'd also make the point that in real-life applications I have never 
found a need to use the * selector, and I haven't seen it used very 
often either.  It is almost _too_ powerful.

>What colour would the elements in the following example be?
>
>   <div>
>     <p>
>       He said
>       <q>
>         <strong>Hello</strong>
>         <em>Gorgeous!</em>
>       </q>
>       to his cat.
>     </p>
>   </div>
>

I *think* I would treat the @locked-together group as having succeeded, 
because the rule doing the over-riding occurs _after_ the 
@locked-together group.  Avoiding back-tracking would probably be 
advantageous anyway in terms of efficiency I'd guess.  Any such approach 
would clearly have to be formalised carefully.

Given that any rules appearing after an author @locked-together group 
must also be author rules, it seems reasonable to imagine that the 
author could take sufficient care over the intended effect without 
having to rely on cancelling his/her own rule groups.

Thus the example given would be treated as if the all the rules followed 
consecutively with no complications i.e.
p * { color: green; }
div { background: white; }
em { color: blue; }
(assuming no _previous_ rule had overridden the application of the P * 
and div rules).

Unfortunately having (maybe) successfully dodged the problem as set, the 
question of what would be the appropriate action if the @locked-together 
group had been in the user stylesheet arises.  In that case it would be 
desirable to check the user style sheet to see if any of its grouped 
rules had been overridden at any point in the cascade.

(The balance here is, I imagine, between:
   - the fact that few users would be likely to have such stylesheets
   - the efficiency with which the de-cascade could occur
and
   - the amount of programming effort involved.)

Another question would be whether the cancelling of the group would be 
total, or only applicable to specific document elements where its rules 
had been overridden.

Regards
-- 
George Lund

Received on Tuesday, 31 July 2001 10:51:52 UTC