In HTML, what is a Color Tag?

Mary McMahon

A color tag is an HTML element which specifies the color of something, such as text, a border, or a background. The use of the color tag in HTML is largely deprecated in favor of using stylesheets, but most browsers will recognize color tags when they are used in the HTML on a page. In CSS, the color tag is used on a regular basis, and numerous CSS tutorials discuss how to harness the color tag to get specific looks and feels.

Color tags tell the web page the correct color in which to display an element, such as text, a border or background element.
Color tags tell the web page the correct color in which to display an element, such as text, a border or background element.

When a color tag is used, there are a number of options for specifying color. One is simply to name the color, such as "black" or "blue." Another is to use a six digit hexadecimal code which specifies a particular color, such as #FFFFFF for white, although people should be aware that sometimes these codes render differently in different browsers when it comes to obscure colors. Yet another option is to use an RGB color, in which the levels of red, green, and blue are specified, as in 0,0,0 for black.

One example of a way in which the color tag was used was in the coloring of text, as in <font color="blue">. For hexadecimal codes, the format <font color="#FFFFFF"> would be used, while RGB codes would be written out as <font color="rgb(0,255,123)"> All of these values for the color tag are only examples; it's possible to find charts with listings of color options online. This trick could also be used to color links, by nesting the "font color=" specification within the link, as in: <a href=""><font color="blue">wiseGEEK</font></a>. For backgrounds, the HTML would read <bgcolor="example">. The color element could also be used in code specifying the characteristics of a border or cell within a table.

Before the color tag was deprecated, it was also used in the "body" tags pertaining to specific documents. These tags could set attributes for the entire page, allowing people to set background color, link color, text color, visited link color, and so forth.

216 colors are regarded as web safe, which means that when they are used with color tags, they are supposed to render the same on any monitor. As many people have learned, however, the situation is a bit more complicated. Colors can look wildly different on different monitors, and it pays to test a web site with several monitors to get an idea of the spectrum of colors which might be seen. Different operating systems can also have trouble with some colors, and some browsers reject colors altogether, which means that similar hues can start to blur together when rendered in grayscale.

You might also Like

Discuss this Article

Post your comments
Forgot password?