1. Home
  2. Computing & Technology
  3. Web Design / HTML

color

By Jennifer Kyrnin, About.com

color Description:

The color property defines the foreground color (usually the text) of the element.

color in CSS Versions:

color Syntax:

color: <color> | attr(<identifier>,color) |inherit

  • <color> - a color code
  • attr(<identifier>,color) - use the color value assigned to the attribute identified in this line (CSS 3)

color Initial Value:

Depends upon the user-agent.

color Applies To:

All elements.

color Inheritance:

This property is inherited.

color Browser Support:

color Examples:

Standard color property

<p style="color : #f00;">This paragraph is red.</p>

Use the text attribute of the body element [blockquote shade=yes]body { color: attr(text,color }[/blockquote] [link url=/od/examples/l/bl_color.htm]See other CSS color examples[/link] _z_webdesign_z_);

color Special Notes:

  • This value is inherited by any borders of the element (the border-color property overrides this).
  • Colors can be defined as hexadecimal (#ff0000), RGB (rgb(255,0,0)), or color names (red).
  • Transparent is a valid keyword and lets any color below the current foreground show through. This keyword was added in CSS 3 to the color property.
  • CSS 3 adds hue-saturation-lightness as a color value as well. For example: hsl(0,100%,50%) is "red" or #ff0000.

More color Information:

Return to the Style Library

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. CSS
  5. Style Properties
  6. CSS Style Property: color

©2008 About.com, a part of The New York Times Company.

All rights reserved.