CSS Basics – everything you need to know

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

#css
10
Ivan Borshchov profile picture
Mar 30, 2021
by Ivan Borshchov
Did it help you?
Yes !
No

Best related

Other by Ivan Borshchov