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

(unknown charset) Re: <style scoped> and the cascade

From: (unknown charset) Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
Date: Thu, 8 Mar 2012 05:22:16 +0100
To: (unknown charset) Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: (unknown charset) Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>, public-html@w3.org
Message-ID: <20120308052216280098.e9ed7392@xn--mlform-iua.no>
Boris Zbarsky, Wed, 07 Mar 2012 22:10:28 -0500:

> No.  For example, I would think that inline style on a node should 
> override <style scoped>.

I see that you parse my language like a computer ...  I of course did 
not intend to convey that <style scope> should overrule the @style 
attribute.

>> Examples: Imagine we have<foo-root>  element as direct child of<body>.
>> And imagine that we have a global<style>  in the<head>  with the
>> following rule:
>> 
>>     body foo-root {background:red}
>> 
>> Simultaneously, inside a<style scoped>  inside the<foo-root>, we have
>> this rule:
>> 
>>     foo-root{background:lime}
>> 
>> Problem: In this case the global style would win.
> 
> Not with my proposal.  That's the whole point of my proposal!

Either you did not understand my proposal, or I have missed something 
in yours. 

So what is it in your proposal that makes the scoped style *in the 
above example* win? I see nothing here: 
<http://lists.w3.org/Archives/Public/public-html/2012Mar/0228.html>

Note that in my example above, then - according to the current rules, 
the global style [from the <style> in the head] is more specific than 
the local, scoped style. Note as well, that with the proposal that I 
tried to present, then this would not be the case: In my proposal, then 
the two rules above, would have - to quote CSS2 - 'the same weight, 
origin and specificity'. Thus, the scoped style would win only because 
it follows *after* the global style.

Or in more detail: Provided that <foo-root> is the direct child of 
<body>, then, in my proposal, the following 'magic' happens: This
  <style scoped>foo-root{background:lime}</style>
is interpreted as if it was this:
  <style>html body foo-root{background:lime}</style>

In another message - 
http://lists.w3.org/Archives/Public/public-html/2012Mar/0256.html - you 
said, quote:

 ''2)  Styles from "a" and "c" (sorted by specificity, etc)''

Unfortunately, you did not include any rules, so I could understand how 
you would count specificity for <style scope>. But I would suggest, 
that if we had this:

<div>
    <style id="a" scoped>* *{color:red}</style>
    Lorem
    <p>
      <style id="b" scoped>*{color:blue}</style>
      Ipsum
    </p>
</div>

Then the rule inside #b would have the same specificity as the rule 
inside #a. 
-- 
leif halvard silli
Received on Thursday, 8 March 2012 04:22:50 UTC

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