Color

Category:CSS Properties

Color

The color property specifies the color of text. There are 140 color names predefined in the HTML and CSS color specification, such as blue, red, coral, brown, etc. Colors also can be specified in various formats; the RGB colors and the HEX colors are the most used ones.

Examples

Color in HEX

Setting the text color for a <h1> element to polo blue using a HEX value.

h1 {
   color: #92a8d1;
}

RGB Color

Setting the text color of a <h1> to crimson using an RGB value.

h1 {
  color: rgb(220, 20, 60);
}

Color Name

Setting the text color for a <p> element to green.

p {
  color: green;
}

Syntax

color: value;

Tips

  • Make sure to choose a background color combined with a text color that makes the text readable

Additional Information

For more information, see http://www.w3schools.com/cssref/pr_text_color.asp

Found a bug in the documentation? Let us know at documentation@code.org