Re: Scoped style sheets.

On Mon, 14 Jul 2008, David Hyatt wrote:
> >
> > One more thing about <style scoped />.
> > 
> > What would be a specificity of CSS rules in scoped style sheet? 
> > Question is in markup:
> > 
> > <html>
> > <style>
> >  body #content p { color:red; }
> > <body>
> >  <div #content>
> >    <style scoped>
> >        p { color:green; }
> >    </style>
> >    <p>what would be the color of this text?</p>
> >  </div>
> > </body>
> > </html>
> > 
> > It appears as <style scoped> should always be more specific than rules 
> > in just a <style>. Yes/no?
> 
> My own opinion is that each scope should constitute a separate author 
> cascade level.  This is how scoped stylesheets work in XBL.  So yes I 
> agree with you and think the spec needs to be amended.

Actually XBL2 doesn't introduce a new cascade level. It just puts the 
sheets in an order that puts them before the sheets in higher scopes:

# Sheets within each origin are always walked from the innermost shadow 
# scope to the outermost shadow scope (with rules in the outermost shadow 
# scope therefore overriding rules of equal specificity in the innermost 
# shadow scope). With this ordering a binding that defines a widget can 
# define a default look for the widget that can then be easily overridden 
# by a client of the widget. For multiple bindings attached to the same 
# element, the sheets are walked from the base binding to the most derived 
# binding.
 -- http://www.mozilla.org/projects/xbl/xbl2.html#binding3

HTML5 doesn't say anything yet about how scoped="" interacts with the 
cascade; it just treats them like any normal author CSS rules.

I don't think we want to make them "stronger" than other rules. The normal 
specificity rules are enough to handle this. Otherwise we end up making 
authors of containing pages having to carefully use !important to override 
scoped styles, which seems like requiring excessive force.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 15 July 2008 01:38:04 UTC