HTML and CSS Reference
In-Depth Information
Thus, to specify white and black, respectively, using percentage notation, the values
would be:
rgb(100%,100%,100%)
rgb(0%,0%,0%)
Using the integer-triplet notation, the same colors would be represented as:
rgb(255,255,255)
rgb(0,0,0)
Assume you want your
h1
elements to be a shade of red that lies between the values for
red and maroon.
red
is equivalent to
rgb(100%,0%,0%)
, whereas
maroon
is equal to
(50%,
0%,0%)
. To get a color between those two, you might try this:
h1 {color: rgb(75%,0%,0%);}
This makes the red component of the color lighter than
maroon
, but darker than
red
. If,
on the other hand, you want to create a pale red color, you would raise the green and
blue levels:
h1 {color: rgb(75%,50%,50%);}
The closest equivalent color using integer-triplet notation is:
h1 {color: rgb(191,127,127);}
The easiest way to visualize how these values correspond to color is to create a table of
gray values. The result is shown in
Figure 9
:
p.one {color: rgb(0%,0%,0%);}
p.two {color: rgb(20%,20%,20%);}
p.three {color: rgb(40%,40%,40%);}
p.four {color: rgb(60%,60%,60%);}
p.five {color: rgb(80%,80%,80%);}
p.six {color: rgb(0,0,0);}
p.seven {color: rgb(51,51,51);}
p.eight {color: rgb(102,102,102);}
p.nine {color: rgb(153,153,153);}
p.ten {color: rgb(204,204,204);}
Figure 9. Text set in shades of gray