CSS COLOR

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.

EXAMPLE

body{
    color: #000000;
}

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.

EXAMPLE

p.one{
    color: #0000ff;
    border: 2px solid;
}
p.two {
    color: #00ff00;
    outline: 2px solid;
}
Categories: CSS