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

Re: attr(x, y)

From: James Craig <work@cookiecrook.com>
Date: Fri, 26 Sep 2003 11:36:04 -0500
Message-ID: <3F746AF4.60303@cookiecrook.com>
To: "www-style@w3.org" <www-style@w3.org>
Cc: David Woolley <david@djwhome.demon.co.uk>

David Woolley wrote:

>>   color: rgb(attr(r,number),attr(g,number),attr(b,number),attr(a,number));
> 
> You need a better example.  This looks like a violation of the principle
> of separating content from style in that you have the actual red, green
> and blue values as attributes of the content.

How about...

h1.pagetitle {
   content: url("/dynamicTitleImage.php?text=" contents), contents;
   }

Now to play devil's advocate...

Regarding the comments above, while I agree that most of the time RGB 
values have no place in content, it depends on the content. Imagine a 
color chart in list form.

<li r="0" b="0" g="0">Color name 1</li>
<li r="0" b="0" g="1">Color name 2</li>
<li r="0" b="0" g="2">Color name 3</li>
<li r="0" b="0" g="3">Color name 4</li>
...
<li r="0" b="0" g="255">Color name 256</li>
<li r="0" b="1" g="0">Color name 257</li>
<li r="0" b="1" g="1">Color name 258</li>
...

li:before {
   width:1em;
   height:1em;
   margin-right:0.5em;
   background-color: rgb(attr(r,number),attr(g,number),attr(b,number));
   }

I'm not sure though, would the ":before" selector be able to inherit 
"attr()" from its parent element? Seems like it would since it can't 
have attributes of its own.

Cheers,
James Craig

-- 
http://www.cookiecrook.com/
Received on Friday, 26 September 2003 12:36:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:23 GMT