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

Ian Hickson ian at hixie.ch
Fri May 30 14:11:40 PDT 2008

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


   td[data-value] {
      background: rgb(calc(255-255*attr("data-value")/10000),

...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.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list