Learn about CSS's most important properties on super-simple examples.

To set the foreground or text color of an element, use the color property:

<p id="sample">
EXAMPLE
</p>

CSS:

#sample {
   color: red;
}

We specified red color so it will look like this:

Change foreground or text color of an element with color property

In 99% of cases, the color CSS property is used only to change the text color of elements.

To set the background or block color of an element, use the background-color property:

CSS:

#sample {
   color: red;
   background-color: yellow;
}

background-color CSS property