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

Re: CSS Variables Draft Proposal

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 16 Feb 2011 16:31:57 -0800
Message-ID: <AANLkTik38_-Yqayh_A_o6YyH_pCHHeOEoJV2848etb9N@mail.gmail.com>
To: David Singer <singer@apple.com>
Cc: Daniel Glazman <daniel.glazman@disruptive-innovations.com>, Christoph Päper <christoph.paeper@crissov.de>, www-style list <www-style@w3.org>
On Wed, Feb 16, 2011 at 4:18 PM, David Singer <singer@apple.com> wrote:
> On Feb 16, 2011, at 20:24 , Daniel Glazman wrote:
>> Le 16/02/11 08:26, David Singer a écrit :
>>> Is it harmful to have variables textually local to the document in which they occur?
>>
>> Assuming your "document" above means "stylesheet", my answer is yes.
>>
>>
>>  <link rel="stylesheet" type="text/css" href="corporate.css"/>
>>  <style type="text/css">
>>    .logo { content: $logoUrl; }
>>  </style>
>>
>> The above - a real test case real users have been asking for more than a
>> decade - is possible only because variables cross stylesheet boundaries.
>> If the logoUrl is changed by the corporate stylesheet, the web page is
>> visually updated w/o any action from the page author.
>
> Oh
>
> What I was suggesting that in the case, where outer.css says:
>
> @var $foo 10px;
> @import url('inner.css')
> div { width $foo }
>
> and inner.css(1) says
>
> div { height $foo }
>
> Then indeed, $foo cascades into the included stylesheet if it's not re-declared there.
>
> But if inner.css(2) says
>
> @var $foo red;
> p { color: $foo }
>
> then the div in outer still gets 10px, as the re-declaration in inner.css is no longer in scope, but paragraphs are red according to inner.css.  This is classical lexical scoping; $foo is shadowed in the nested scope.
>
> I am not sure what the scoping rule would be to enable what you give [above], and at the same time avoid unintended clashes/redefinitions.

The idea is that there *isn't* such a scoping rule.  We'll just solve
the clash problem with a separate mechanism.

~TJ
Received on Thursday, 17 February 2011 00:32:49 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:37 GMT