Color Values

#RRGGBB

This is a hex-pair notation familiar to authors using traditional HTML. In this format, the first pair of digits corresponds to the red level, the second pair to the green, and the third pair to the blue. Each pair is in hexadecimal notation in the range 00-FF. Thus, a “pure” blue is written #0000FF, a “pure” red is written #FF0000, and so on.

#RGB

This is a shorter form of the six-digit notation described above. In this format, each digit is replicated to arrive at an equivalent six-digit value; thus, #F8C becomes #FF88CC.

rgb (rrr.rr%,ggg.gg%,bbb.bb%)

This format allows the author to use RGB values in the range 0% to 100%, with decimal values allowed (e.g., 75.5%). The value for black is thus rgb (0%,0%,0%), whereas “pure” blue is rgb (0%,0%,100%).

rgb (rrr,ggg,bbb)

Similar to the previous value; the differences here are that the accepted range of values is 0-255 and only integers are permitted. Not coincidentally, this range is the decimal equivalent of 00-FF in hexadecimal. In this format, “pure” green is rgb (0,255,0), and white is represented as rgb (255,255,255).

<keyword>

One of 17 recognized keywords based largely on the original Windows VGA colors. These keywords are aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow. Browsers may recognize other keywords, such as the X11 color keywords that are documented in the W3C CSS3 Color Module specification.

Get CSS Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.