CSS background-color Property

Description

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

Initial value
transparent
Applies to
All elements
Inherited
No
Media
Visual
Computed value
The computed color
Animatable
Yes
CSS Version
CSS1, CSS2, CSS3
JavaScript syntax
object.style.backgroundColor

Syntax

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;

Values

  • <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

Example

.class {
   background-color: #9C9A9C;
}

Give it a Try

Click the button below to experiment with this property.

Give it a Try!

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
412113.51
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
≤37184Yes1Yes