Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

color (CSS property)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Inherited Initial Version
Yes CSS1, 2.1
color: { color | inherit } ;

Example

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

#example {
  color: red;
}

Try it yourself!View all demos

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.

Value

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

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

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

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters