W3C home > Mailing lists > Public > www-style@w3.org > September 2011

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 19 Sep 2011 16:43:52 -0700
Message-ID: <CAAWBYDBrx46FRqpKpEKq5kA3WODZat9V7Qpe7Nq0S8xY7eBMMg@mail.gmail.com>
To: fantasai <fantasai.lists@inkedblade.net>
Cc: www-style@w3.org
On Mon, Sep 19, 2011 at 4:12 PM, fantasai <fantasai.lists@inkedblade.net> 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
>> <http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-September/033222.html>.
> 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

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:04 UTC