Text colors in HTML




Basic specification of color

Today there really is only one way to specify the color of an element, and that is STYLE="color:colorNumber". In older literature you can find the attribute COLOR="", and most likely it will work on some browsers, but it isn't a viable solution for a modern web site.

In HTML all colors have a number, e.g. black is #000000 and white is #FFFFFF. Some colors are also defined as a named color. Therefore it doesn't matter if you use STYLE="color:black" or STYLE="color:#000000". In theory at least. Since using a named color only works for some colors, you can also expect that not all browsers can understand all named colors. Therefore: The recommendation is to use the numbers!

Black is the default color for normal text. A string of white text will look like this as code:

Here the text is normal, <SPAN STYLE="color:#FFFFFF">here the text becomes white,</SPAN> and here the text returns to normal.


When shown on the page, it looks like this:

Here the text is normal, here the text becomes white, and here the text returns to normal.





Color gradients on text

Several places on the net you can find suggestions to how you get color gradients on text. The suggested solutions, based on CSS3/webkit, do not work for all browsers, and currently there is no good solution for color gradients on text.