The background-color property

The background-color property sets a background color of an element. The property value is any color units. Default value: transparent.

Syntax

cssselector {
  background-color: color;
}

Example

Let's give the block some background color:

html<div id="elem"></div>
css#elem {
  background-color: #9595ff;
  width: 300px;
  height: 100px;
}

Результат:

See also

  • the background property
    that is a shorthand property for a background
  • the background-image property
    with that you can set a background image for a block