HTML and CSS Reference
In-Depth Information
Simple and straightforward, isn't it? Figure 8 shows a few more examples:
h1 {color: silver;}
h2 {color: fuchsia;}
h3 {color: navy;}
Figure 8. Naming colors
Of course, you've probably seen (and maybe even used) color names other than the
ones listed earlier. For example, if you specify:
h1 {color: lightgreen;}
As of the CSS3 color specification, the 16 colors from HTML 4.01 have been subsumed
into a longer list of 147 color keywords. This extended list is based on the standard
X11 RGB values that have been in use for decades, and have been recognized by brows-
ers for many years, with the addition of some color names from SVG (mostly involving
variants of “gray” and “grey”). A table of color equivalents for all 147 keywords defined
in the CSS Color Module Level 3 is given in “Color Equivalence Table” on page 28 .
Fortunately, there are more detailed and precise ways to specify colors in CSS. The
advantage is that, with these methods, you can specify any color in the color spectrum,
not just 17 (or 140) named colors.
Colors by RGB and RGBa
Computers create colors by combining different levels of red, green, and blue, a com-
bination that is often referred to as RGB color . Each point of display is known as a pixel,
which is a term discussed earlier in the chapter. Given the way colors are created on a
monitor, it makes sense that you should have direct access to those colors, determining
your own mixture of the three for maximum control. That solution is complex, but
possible, and the payoffs are worth it because there are very few limits on which colors
you can produce. There are four ways to affect color in this manner.
Functional RGB colors
There are two color value types that use functional RGB notation as opposed to hexa-
decimal notation. The generic syntax for this type of color value is rgb(color) , where
color is expressed using a triplet of either percentages or integers. The percentage values
can be in the range 0% - 100% , and the integers can be in the range 0 - 255 .
Search WWH ::

Custom Search