Re: CSS3 Rule weights

On 05/22/2015 09:37 AM, Samwul Datong wrote:
> CSS3 uses the cascading set of rules and the !important keyword to determine which style rule among many conflicting rules
> should apply to an object/item.
>
> However, with the heavy use of classes in css frameworks, the current system might not be totally appropriate to address all
> use cases.
>
> I'm proposing a new simple css rule-weight property which can be added to any set of rules. The simple idea is that a set of
> rules with a heavier weight should take precedence over lighter weights.
>
> e.g.
> .class1 {color:blue; font-size:1em; rule-weight:10}
> .class2 {color:red; background-color:#b2b2b2; text-align:center; rule-weight:50}
>
> <div class="class1 class2">Hello World</div>
>
> Here, for any rules defined in both class1 and class2, the rules in class2 would take precedence because class2 has a higher
> rule-weight than class1.
>
> This should make working with stylesheets simpler and easier to understand

Random numerical constants like this generally make a mess of things,
and I'm guessing people will just throw random large numbers at their
style sheets in order to "fix" some problem that they didn't take the
time to understand. We already have a similar issue with z-index
(people set it to MAX_INT when they want something to "win" the top
position), and that's even a simpler problem than cascading.

~fantasai

Received on Sunday, 24 May 2015 15:38:53 UTC