CSS Color

The CSS color property defines the foreground color for an element.

Setting Color Property

The color property typically defines the color of the text content of an element.

For instance, the color property specified in the body selector defines the default text color (foreground color in general) for the whole page.

Colors in CSS most often specified by the following methods:

  • a HEX value – like “#ff0000”
  • an RGB value – like “rgb(255,0,0)”
  • a color name – like “red”

Look at CSS Color Names for a complete list of possible color names.

Affect of Color Property on Borders and Oulines

The color property is not just for text content, but for anything in the foreground that takes a color value. For instance, if border-color or outline-color value hasn’t been defined explicitly for the element, the color value will be used instead.

Note:The 'color' property normally inherits the color value from their parent element, except the case of anchor elements.