Software and eBooks for your Palm-powered PDA.

Google

Adding Color to HTML documents

Specifying Color Values

There are several HTML tags that allow you to control the color of text or background in HTML documents. In each of these tags, the color to be displayed is specified as a # sign followed by a 6-digit hexadecimal number. The six digits in this number represent three values, each of which is coded as a two-digit value. The three two-digit values are the amount of red, green, and blue, respectively that compose the color. In other words, the color to be displayed is constructed by mixing red, green and blue in the proportions that are specified.

For example, if I wanted to display a color that was very red, the value that I would code would be #FF0000. Similarly, the value for green is #00FF00, and the value for bright blue is #0000FF. Other colors are constructed by mixing the primary colors. Yellow (#FFFF00) is a mixture of red and green and magenta (#FF00FF) is a mixture of red and blue. Black is the absence of all colors (#000000) and white is all colors mixed together (#FFFFFF).
Search:
Keywords:
In Association with Amazon.com

HTML Tags that Control Color

There are several tags that allow you to control the color of text and background in your documents. Here I'm going to explain how to control color with the BODY, FONT and TABLE tags.

The BODY tag allows you to set the default color of the background, text and links in a document. This tag,

<BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#FF00FF" ALINK="#FF0000" VLINK="#0000FF">
for example, would set the default color of the background to black, the color of text to white, the color of unfollowed links to magenta, a clicked link to red, and a followed link to blue. The BODY tag sets default colors for background and text.

The default color of text can be over-ridden with the FONT tag. To change the color of text to cyan, we would use this tag:

<FONT COLOR="#00FFFF">
This would cause all text to appear in a cyan colored font, between the FONT tag and the succeeding
</FONT>
tag.

Finally, we can override the default colors of the background with the TABLE and TD tags. The TABLE tag allows us to set the default background color of all cells in the table, using the BGCOLOR option.
This tag
<TABLE BGCOLOR=#FFFFFF">
sets the default color of cells to white, while this tag
<TD BGCOLOR="#AF00AF">
sets the color of an individual cell to a dark magenta.
Thiswhitetable
containsamagenta
cell. 

Return to Top of Page

You can find a color selection chart here.



Rique's Tutorials Character Set for Web Publishing Quick Quide to HTML Tags
Rique's Navbar