For the pages of this tutorial, we have used a solid white color that makes for a clean and non-interfering (even if not dramatic) backdrop. No, it is not very exciting, but it is readable.
With some modifications to the <body> tag (introduced way back in lesson 1), you can add a solid color background to your web page. But before we show you how to do the fancy color stuff, we must first talk about RGB color values and their "hexadecimal" representation.
In a web browser, you have at your disposal many system colors to color text and backgrounds. Each color is identified by its
Red- Green- Blue (RGB) values, three numbers that range from 0 to 255, each of which represents the intensity of the Red, Green, or Blue component of the desired color. Maximum values of all three (R=255, G=255, B=255) produce the color white and minimal values (R=0, G=0, B=0) produce black. All other colors are represented by different of RGB triplets.Here is the tricky part. Rather than identifying a color as something like "102,153,255" each number is converted from base 10 (normal everyday numbers, digits from 0,1,2,3,4,5,6,7,8,9) representation to hexadecimal, base 16 (digits from 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). Why? Hexadecimal is more easily and more efficiently understood by computers. So for the color example above, we would write in hexadecimal as "6699FF". In this example, "66" is the Red value, "99" the Green, and "FF" the Blue.
Here are some hexadecimal examples of different colors:
Color | Hex Code | Color | Hex Code | |
---|---|---|---|---|
xx oo xx | FFCCCC | xx oo xx | 3300FF | |
xx oo xx | 33FF66 | xx oo xx | AA0000 | |
xx oo xx | 663300 | xx oo xx | 9900FF | |
xx oo xx | 000077 | xx oo xx | FFFF00 | |
xx oo xx | EEEEEE | xx oo xx | 888888 | |
xx oo xx | 444444 | xx oo xx | 000000 | |
Now, don't panic about having do a bunch of numerical conversions! There are many tools that will let you click on a color and they will provide the hexadecimal representation. Many color tools are available from those folks at Yahoo.
But better yet, many browsers support standard shorthands for these 16 colors (those Windows VGA favorites):
|
||||
Color | Name | Color | Name | |
xx oo xx | aqua | xx oo xx | black | |
xx oo xx | blue | xx oo xx | fuchsia | |
xx oo xx | gray | xx oo xx | green | |
xx oo xx | lime | xx oo xx | maroon | |
xx oo xx | navy | xx oo xx | olive | |
xx oo xx | purple | xx oo xx | red | |
xx oo xx | silver | xx oo xx | teal | |
xx oo xx | white | xx oo xx | yellow |