[thelist] CSS: colour attributes
Mark Gallagher
mark at cyberfuddle.com
Sun Aug 11 12:26:00 CDT 2002
Frank wrote:
>
> As far as I understand, colour can be specified in a number of ways
> in HTML and CSS
>
> "white" a limited number of named colours.
>
> "#FFFFFF" hexadecimal, three groups of two.
>
> rgb(255,255,255) three groups representing, red, green blue.
>
> I've been seeing this "#FFF" all over the place for a long time. At
> first, I thought that it was simply sloppy code. Then I found Eric
> Meyer using it. I can't seem to find a reference that details the
> composition of the statement, even on the w3c. I'm feeling kind'a
> stumped, kind'a dumb.
As you correctly pointed out, colour can be specified as #FFFFFF
(white), three groups of two. These three groups are: RRGGBB, or
two-digit hex Red, two-digit hex Green, and two-digit hex Blue.
Where R1 and R2 are equal, G1 and G2 are equal, and B1 and B2 are
equal[0], it's not necessary to specify the second R, G, and B.
So:
#FFFFFF can be written as #FFF, #CCDD33 can be written as #CD3, and so
on - the browser will assume the second digit in each group matches the
first.
Values like #213D94, on the other hand, cannot be shortened. Nor can
#080008 - *all* groups must contain digits of equal value (within that
group).
[0] Fans of the Australian BC's kids' shows will know that not all B's
are equal
--
Mark Gallagher
Desperately attempting - and failing - to stay on topic since 1999
fuddleriffic - http://cyberfuddle.com/
blog - http://cyberfuddle.com/infinitebabble/
More information about the thelist
mailing list