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

Re: <style scoped> and the cascade

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 7 Mar 2012 14:02:11 -0800
Message-ID: <CAAWBYDCbu3=AXSTtZSNXSoPOnWzUT463JDu-4=-RRgVYCD9mOA@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: public-html@w3.org
On Wed, Mar 7, 2012 at 1:52 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 3/7/12 4:18 PM, Tab Atkins Jr. wrote:
>>
>> Hmm, true.  The problem is worsened by the fact that scoped
>> stylesheets provide an "implicit prelude" that restricts their
>> selectors without increasing specificity, so global selectors that are
>> trying to target the same elements will often naturally be longer.
>>
>> I support Boris's change.
>
>
> There's a similar question about the interaction between two scoped
> stylesheets scoped to nested elements, actually.  Consider this testcase:
>
>  <div>
>   <style id="a" scoped></style>
>   <p>
>     <style id="b" scoped></style>
>   </p>
>   <style id="c" scoped></style>
>  </div>
>
> 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)
>  3)  !important styles from "b"
>  4)  !important styles from "a" and "c" (sorted by specificity)
>  5)  !important global styles
>
> Thoughts?

Yes, the cascade order should follow the nesting order, with deeper
scopes winning over higher scopes (and the reverse for !important).

Once you have this principle, it generalizes to the non-scoped case,
where the global scope is shallower than any element scope.

~TJ
Received on Wednesday, 7 March 2012 22:03:00 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:39:30 UTC