| Previous | Next
ColorsCSS has several properties for changing the color of various items:
CSS uses a 24-bit color space to specify colors, much as HTML does. Always keep in mind, however, that just because you can specify a color doesn't mean any given device can render it. A black-and-white printer isn't going to print red no matter how you identify it; it might give you some nice shades of gray though. Like many other properties, color depends on the medium in which the document is presented. The simplest way to choose a color is through one of these 16 named constants: Beyond this small list, you can specify the color of an item by specifying the three components--red, green, and blue--of each color, much as you do for background colors on HTML pages. Each component is given as a number between 0 and 255 with 255 being the maximum amount of the color. Numbers can be given in decimal or hexadecimal. For example, these rules use hexadecimal syntax to color the
If you prefer, you can specify the color as decimals separated by commas inside an
You can also specify the color as percentages of each primary color from 0 to 100%. For example, the previous rules can be rewritten like this:
|