color (CSS property)

Spec
Inherited Initial Version
Yes CSS1, 2.1
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

color: { color | inherit } ;

Description

The color property defines the foreground color of an element; in essence, this means it defines the color of the text content. If a border-color value hasn’t been defined explicitly for the element, the color value will be used instead.

It’s always good practice to set a background-color, as we set color to ensure that conflicts don’t arise between these values and any previous declarations or styles contained within user style sheets.

Example

This style rule sets the color red for text within the element with ID "example" :

#example {
  color: red;
}

Value

color takes any valid CSS color value. The initial value for this property depends on the user agent.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Internet Explorer for Windows versions up to and including 7 don’t support the value inherit.

User-contributed notes

ID:
#5
Contributed:
by Louis Lazaris
Date:
Thu, 27 Jan 2011 17:52:53 GMT

It would seem that the color property should affect elements created on a canvas element (don't they qualify as "foreground" elements?), but from my testing, this doesn't seem to be the case.

Not sure if that can or should be incorporated into the description here.

Related Products