Computing easily the weight/origin of a declaration

Section 6.4.1 of CSS2 defines the weight/origin order. here is very
simple way to compute this order and sort declarations :

Assign a numerical value 'importance' to each declaration :

	0.5	for author's declarations
	0.25	for user's declarations
	-2	for user agent's declarations

Apply f(x)=1/x to !important declarations.

Then we have, as it is defined in cascading order

user!important > author!important > author > user > software!important > software
4 > 2 > 0.5 > 0.25 > -0.5 > -2

If you add this number at the beginning of the (a,b,c) value of
section 6.4.3, you can very easily sort by lexicographic order and
determine which declarations apply to a given element.


</Daniel>

Received on Sunday, 26 April 1998 11:54:54 UTC