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:

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

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
Received on Thursday, 8 March 2012 12:28:07 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:45:50 UTC