Changing the font color with the <font> tag

To control the color of a font, we use the color attribute with a color value. For the value, you can specify either the name of the color or a RGB value. A name of the color could be like "red", "green", "blue", etc.

To select colors with RGB values, set the color attribute to "RRGGBB", in which the first two letters RR stands for red. Each of the 2 R's can be substituted with a number value 0 - 9 or the letters A - F. "0" represents absence of the color red, while the letter "F" represents the most amount of color red. The next two letters GG stands for green and can be substituted with the same values as for the color red. The last two letters BB stands for blue and can be substituted with the same values as for the previous two colors.

Listing 2 examples shows examples of changing color of a font with using a name or RGB value of color.

Listing 2 Changing the font color
Color Name Color value Output
<font color="red">Red</font> <font color="FF0000">Red</font> Red
<font color="green">Green</font> <font color="00FF00">Green</font> Green
<font color="blue">Blue</font> <font color="0000FF">Blue</font> Blue