Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Background color – CSS

Demo

Summary

To change the background color of an element using CSS, use the background-color property:

selector {
  background-color: red;
}

Details

You can use RGB, hex, HSL, and keyword values for the background-color property.

Exercises

First, recreate the CSS code from the Demo section in your CSS file. Then try changing the value for the property.

References

background color on MDN

Back to: CSS Reference > CSS Properties