Re: CSS Variables Draft Proposal

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 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