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

Re: CSS Variables Draft Proposal

From: David Singer <singer@apple.com>
Date: Thu, 17 Feb 2011 08:18:55 +0800
Cc: Christoph Päper <christoph.paeper@crissov.de>, www-style list <www-style@w3.org>
Message-Id: <B50BE9CC-B64D-4D62-B000-5821465224AD@apple.com>
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>

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 below, and at the same time avoid unintended clashes/redefinitions.

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.
> </Daniel>

David Singer
Multimedia and Software Standards, Apple Inc.
Received on Thursday, 17 February 2011 00:20:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:56 UTC