W3C home > Mailing lists > Public > public-html@w3.org > March 2012

Re: <style scoped> and the cascade

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Thu, 08 Mar 2012 13:27:38 +0100
Message-ID: <4F58A5BA.5060907@lachy.id.au>
To: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
CC: Boris Zbarsky <bzbarsky@MIT.EDU>, public-html@w3.org
On 2012-03-08 01:58, Leif Halvard Silli wrote:
> Boris Zbarsky, Wed, 07 Mar 2012 16:52:46 -0500:
>> For descendants of the<p>, I would think that the cascade order should be:
>>
>>    1)  Global stylesheets
>>    2)  Styles from "a" and "c" (sorted by specificity, etc)
[Edit: Normal styles from "b"]
>>    3)  !important styles from "b"
>>    4)  !important styles from "a" and "c" (sorted by specificity)
>>    5)  !important global styles
>>
>> Thoughts?

Why is the priority of the !important rules reversed?  Why should an 
!important global rule override an !important scoped rule?

I would expect this to work:

<style>
p { color: red !important; }
</style>
<div>
   <style scoped>
   p { color: green !important; }
   </style>
   <p>This line should be green.</p>
</div>

This would require the weights to be determined like this:

1. user agent declarations
2. user normal declarations
3. author normal declarations:
    a) From global styles
    b) From scoped styles (ordered hierarchically)
4. author important declarations
    a) From global stylesheets
    b) From scoped stylesheets (ordered hierarchically)
5. user important declarations

> Which makes me wonder: What's the problem<style scope>  is supposed to
> solve? Isn't the purpose to *override* the effect of the cascade?

No.  The purpose is only to prevent styles from leaking to elements 
outside of the specified scope.

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/
Received on Thursday, 8 March 2012 12:28:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:17:46 GMT