W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2007

[Whatwg] [whatwg] Color attributes

From: Simon Pieters <zcorpan@gmail.com>
Date: Fri, 27 Jul 2007 13:07:26 +0200
Message-ID: <op.tv4eiokb7a8kvn@hp-a0a83fcd39d2>
On Thu, 05 Jul 2007 23:43:55 +0200, Simon Pieters <zcorpan at gmail.com>  
wrote:

> Color attributes in HTML have special processing.
>
> Some tests/demos:
>
>      http://simon.html5.org/test/html/parsing/color-attributes/
>
> https://bugzilla.mozilla.org/attachment.cgi?id=188040 contains further
> tests and an algorithm that is supposed to match what IE does. The only
> flaw in that algorithm AFAICT is that there is a step missing before the
> first step: match the value against the list of supported color keywords.
>
> For reference, the complete algorithm would be:
>
>     1. If the value case-insensitively matches a color keyword, use that  
> and
>        abort these steps. [CSS3COLOR]

"transparent" is also to be treated as a keyword, meaning transparent. (It  
seems that IE treats transparent as black for text color, but that's a CSS  
thing.)

>     2. Trim all but the first 128 chars from the string.
>     3. If it exists, strip the first leading #.
>     4. Replace non-valid-hex chars with 0s.
>     5. Lower-case the string.
>     6. Make string length a multiple of 3 and a minimum of 3 by  
> appending 0s.
>     7. Split the string into 3 equal segments.
>     8. Trim all but the right-most 8 chars from each segment.
>     9. If segment length is 1, left-pad each segment with a 0, else:
>    10. While segment length is greater than 2 and the first char of each
>        segment is equal to 0, trim the left-most char from each segment,
>        then:
>    11. Trim all but the first 2 chars from each segment.
>    12. Join the segments and append them to a # char to create the final
>        string.
>
> [...]

-- 
Simon Pieters
Received on Friday, 27 July 2007 04:07:26 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:36 UTC