English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Basic Tutorial

CSS Box Model

CSS3Basic Tutorial

CSS Reference Manual

CSS @rules (RULES)

CSS Color (Color)

The CSS color property defines the foreground color of the element.

Set color properties

ThecolorProperties usually define the color of the text content of the element.

For example, in the selectorcolorspecified attributebodyDefine the default text color for the entire page (usually the foreground color).

body {color: #000000;}
Test to see‹/›

Colors in CSS are usually specified by the following methods:

  • Hexadecimal Values-For example, '#ff0000'

  • RGB Values-For example, 'rgb('255,0,0)

  • Color Names-such as 'red'

View CSS color names to get the complete list of possible color names.

The effect of color properties on borders and outlines

ThecolorProperties are not only used for text content but also for all content using color values in the front-end. For example, if the element has not been explicitly definedborder-colororoutline-colorValue, then the color value will be used.

p.one {
    color: #0000ff;
    border: 2px solid;
    }
p.two {
    color: #00ff00;
    outline: 2px solid;
    }
Test to see‹/›

Note:ThecolorProperties usually inherit the color value from their parent element,AnchorExcluding Elements.