Re: Suggestion for @global to help with <style scoped>

On Mon, Sep 19, 2011 at 4:12 PM, fantasai <> wrote:
> On 09/19/2011 03:58 PM, Tab Atkins Jr. wrote:
>> Summary
>> -------
>> HTML is defining<style scoped>  in a way which best matches author
>> intuitions, but which is limited in some ways.  I propose @global as a
>> way to get around those limitations while maintaining the
>> intuitiveness benefits.  Hixie wrote an email explaining the relevant
>> reasoning and suggesting this proposal at
>> <>.
> What's the use case for this, i.e. do we actually need to solve this
> problem?

A concrete use-case is provided at the very top of Hixie's email:

<body class="archive">
    <style scoped>
      section > h1 { border-bottom: solid; }
      body.homepage h1 { color: red; }
      body.archive h1 { color: gray; }
    <h1>Hello</h1> <!-- this changes colour based on whether it's on a
                        page with <body class=homepage> or <body
                        class=archive> -->

Here, you want to style just the given section, without styles leaking
out into the rest of the document, thus you use <style scoped>.
However, you want to change the styling of the <h1> based on context
outside of the scope, in this case the class of the <body>.  (Implicit
in this example is the fact that the same section will be generated on
multiple pages.)


Received on Monday, 19 September 2011 23:44:48 UTC