[Prev][Next][Index][Thread]

RE: 'legal' / 'important' and cascading order



Scott Preece wrote:
>Perhaps I'm missing something - why can't you do the same thing in
>either case?  That is, if you have weights on individual properties
>within a rule, you can split the rule into multiple rules, one
>containing the
>unweighted properties and one containing the rules with a given weight.
>The separated rules could then be treated as you suggest.

You definitely can do this - in fact, it is probably the easiest and
best way to implement per-rule weighting.
>
>Frankly, it seems to me we should allow the weight to be put in both
>places, which gives the author maximum flexibility at the cost of a
>small additional amount of work in parsing.  That's why we build tools
>-
>to make life easier for tool users.

Unfortunately, it's not just a small additional  amount of work in
parsing - it can make the cascade considerably less efficient.  Consider
this:

H1 {
	font-size: 12pt;
	font-weight: bold !important;
	text-align: left;
	text-decoration: underline !important;
	font-family: Arial
}

This will get split into five declarations, unless you do some resolving
of rules with identical selectors, or keep up to three copies of a
grouping at the same time during parsing (for important, legal and
normal), either of which is not necessarily just a small amount of work.
 It also confuses the issue of parsing even a bit more to have the
"!important" token at the end of the value - it would have been much
easier to parse had these attributes been set at the beginning of each
declaration, e.g.
	!important font-weight: bold;

However, I personally am intensely in favor of per-group-only
declarations, e.g. (for the style above):
H1 !important {
	font-weight: bold;
	text-decoration: underline	}
H1 {
	font-size: 12pt;
	text-align: left;
	font-family: Arial	}

One of the goals of CSS is, I believe, to keep the cost of an initial
implementation low; I think it's wasteful to add this very small
convenience that probably won't be used much anyway, when the
implementation cost is non-trivial.

	-Chris
Chris Wilson
cwilso@microsoft.com
-[-



Follow-Ups: