3-
Adding Color
Adding colors to web pages is relatively simple. Each color has a six digit
code assigned to it with a number sign in front of it. This code is the
Hexadecimal (Hex) Triplet value. Instead of using a number system that goes from
0 to 9, Hex uses a system that starts with 0 goes to 9 and then from A-F. This
allows one digit to stand for 16 values instead of just ten.
The first two numbers of the code is the amount of red.
#FF0000 is red. The second two numbers is the amount of green.
#00FF00 is green. The last two numbers represents
the amount of blue. #0000FF is blue. Any
combination of these codes can be used to create any color. A list colors and
their codes is found on the
colors page in the reference area.
To change the default colors on the whole page, you need to change an
attribute to the <body> tag. The following are some attributes you can have
inside the body tag:
| bgcolor="..." |
Sets the background color of the page. |
| text="..." |
Sets the color of the text. |
| link="..." |
Color of links. |
| vlink="..." |
Visited link color. |
| alink="..." |
Active link color. |
Note that you do not have to define all of these attributes. If you do not
set a color for a visited link, for example, the color of visited links will be
set by the browser looking at the file.
An example of a page with blue background, white text and with red links.
(we'll learn more about link tags next)
<html>
<head>
<title>My Colorful Page</title>
</head>
<body bgcolor="#0000FF" text="#FFFFFF" link="#FF0000">
<p>Regular Text<br>
<a href="link.html">Link</a></p>
</body>
</html>
Try it yourself!