The background-color property sets the background color of an element. The color is drawn behind any background images.

  • Initial valuetransparent
  • Applies toAll elements
  • InheritedNo
  • MediaVisual
  • Computed valueThe computed color
  • AnimatableYes
  • CSS VersionCSS1, CSS2, CSS3
  • JavaScript
Formal syntax: <color> 

background-color: green;
background-color: #3366FF;
background-color: rgb(51,102,255);
background-color: rgba(51,102,255,1);
background-color: hsl(225,100%,60%);
background-color: hsla(225,100%,60%,1);
background-color: transparent;
  • <color>Accepts a single color as its value, which can be a keyword, hex, RGB, RGBa, HSL or HSLa color value.
  • transparentThe default value; you will be able to see the elements behind the element in question showing through it.
  • inherit
.class {
   background-color: #9C9A9C;

Click the button below to experiment with this property.

Give it a Try!


Last updated on 23rd March 2014 By Rene Spronk

View All CSS Properties

Errors? Please help to keep this list up to date, If you find any errors, please contact us, so that we can get them fixed.