W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2008

[whatwg] [Slightly OT(?)] Programmatically defined styles [Re: Superset encodings [Re: ISO-8859-* and the C1 control range]]

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 30 May 2008 21:11:40 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0805302100260.12907@hixie.dreamhostps.com>
On Fri, 30 May 2008, ?istein E. Andersen wrote:
> > [I wrote:]
> >> PS: How should colour be added to tables like these in HTML5 with
> >>     neither of the attributes bgcolor and style?
> >
> > Class attribute and external stylesheets. (Possibly a data-* attribute.)
> 
> I actually thought this might be one of the cases that could reasonably
> and legitimately be solved using the style attribute (which was, I believe,
> still absent from the draft when my PS was written), so it is interesting
> to see that you think otherwise. I would like to point out that your suggested
> solution would require a style sheet along the following lines: [...]
> 
> Adding 256 classes (of which 100--200 are actually used in each document)
> is certainly feasible.
> 
> However, this solution would not seem to be practical for a colour 
> scheme using a larger number of colours. Would your mantra remain the 
> same given, e.g., 256^2 or 64^3 distinct shades of colour? If not, where 
> should the boundary be drawn?

I was thinking more along the lines of:

   <td data-value="2838">..</td> <!-- value ranges from 0..10000 -->

...with:

   td[data-value] {
      background: rgb(calc(255-255*attr("data-value")/10000),
                      calc(255*attr("data-value")/10000),
                      calc(127-63*abs(attr("data-value")/10000-0.5))));
   }

...which would require some changes (in particular, adding "abs()" and 
allowing colour calculations) to the calc() and attr() proposals, but 
would be significantly better than hard-coding the colours into the 
markup or having a bazillion classes.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 30 May 2008 14:11:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:02 UTC