Sets the color of the text of the object.

{ color: sColor }


Variant that specifies or receives a valid HTML color name or RGB value.

This property has no default value. It is inherited.

These are different ways to specify a color (in this example, red):

em {color: red}              /* natural language / CNS */
em {color: #F00}             /* #RGB */
em {color: #FF0000}          /* #RRGGBB */
em {color: rgb 1.0 0.0 0.0}  /* float range: 0.0 - 1.0 */

Some browsers do not recognize color names, but all browsers should recognize RGB color values and display them correctly.

The following example uses the color property to change the text color of an object. This example uses a call to an embedded (global) style sheet to change the text color to red when an onmouseover event occurs:

    .color1 {color:red}
    .color2 {color:}
<span style="font-size:14" onmouseover="this.className='color1'" onmouseout="this.className='color2'"> . . .

a, address, applet, b, big, blockquote, body, button, caption, center, cite, code, col, colgroup, custom, dd, defaults, dfn, div, dl, dt, em, fieldset, form, hn, html, i, input type=button, input type=checkbox, input type=file, input type=image, input type=password, input type=radio, input type=reset, input type=submit, input type=text, li, ol, option, p, s, select, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

Community Additions