W3C home > Mailing lists > Public > www-style@w3.org > April 1996

'legal' / 'important' and cascading order

From: Wolfgang Rieger <rieger@bse.de>
Date: Mon, 22 Apr 1996 14:59:22 +0200
To: www-style@w3.org
Message-Id: <317b6d73.8434392@mail.space.net>
The following example shows a problem connected with the use of
'legal'or 'important' and the cascading order:

Example:

Rule 1:

spec1 { prop1 : value1 !important;
	prop2 : value2; }
Rule 2:

spec2 { prop1 : value1;
	prop2 : value2 !important; }

Assume that spec1 and spec2 both apply to the element under
consideration. Now, when looking for the value of prop1, rule1 takes
precedence other rule2, while when looking for the value of prop2,
rule2 takes precedence over rule1.

To handle this, one could use a data structure where simple selectors
are paired with declaration lists (i.e. groups of property-value
pairs). In this case, (in effect) one would have to sort lists of such
strutures with matching simple selectors each time one is looking for
a property.

Or one could use simple selectors paired with property-value pairs.
This list would have to be sorted only once (according to the rules
given in section 3.2 of the draft). The first pair with matching
selector and property value would provide the property value.

However, there are two drawbacks with the second approach:

1. To find the value for a given property, one would have to match a
list with all property-value pairs and matching selectors.
2. If there is a rule with 10 simple selectors and 20 property-value
pairs, this rule alone produces a list with 200 items.

Finally, one could have a list of property-value-pairs with
corresponding simple selectors. This list could be sorted once only,
too. But the matching the selectors would be relatively slow. This may
be no problem when formatting small HTML documents, but when
formatting large SGML documents this could be a performance issue.

I do not know what others think about this (and I would like to
learn). Maybe I'm just dumb and don't see the obvious.

However, IMHO there is no big use in being able to specify weight on
the declaration level. As far as I can see, it would be sufficient to
specify weight on the rule level. In this case, one would have instead
of the example given above the following rules:

spec1 { prop1 : value1; !important }
spec1 { prop2 : value2; }
spec2 { prop1 : value1; }
spec2 { prop2 : value2; !important }

Formal grammar:
---------------

To achieve this, the productions for 'rule' and 'declaration' in the
formal grammar would have to be changed to:

rule:
	selector [ ',' selector ]*
	'{' declaration [ ';' declaration ]* prio? '}'

declaration:
	property ':' expr

Regards

Wolfgang Rieger
Buero fuer Software-Entwicklung           Email: rieger@bse.de
                                          WWW  : http://www.bse.de/
Rosenheimer Str. 214                      Phone: +49 89 497738	
81669 Munich, Germany                     Fax  : +49 89 497738
Received on Monday, 22 April 1996 08:57:34 GMT

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