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

Computing easily the weight/origin of a declaration

From: Daniel Glazman <Daniel.Glazman@der.edfgdf.fr>
Date: Sun, 26 Apr 1998 17:56:53 +0100 (WET DST)
Message-Id: <199804261656.RAA07469@cli51ak.der.edf.fr>
To: www-style@w3.org
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 GMT

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