CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

CSS background-color Property

Topic: CSS3 Properties ReferencePrev|Next

Description

The background-color CSS property sets the background color of an element. You can set color of the background either through a color value or the keyword transparent.

The background of an element is the total size of the element, including padding and border (but not the margin). See the box model.

The following table summarizes the usages context and the version history of this property.

Default value: transparent
Applies to: All elements
Inherited: No
Animatable: Yes. See animatable properties.
Version: CSS 1, 2, 3

Syntax

The syntax of the property is given with:

background-color color | transparent | initial | inherit

The example below shows the background-color property in action.

body {
    background-color: yellow;
}
h1 {
    background-color: rgb(255,0,0);
}
p {
    background-color: #00ff00;
}

Property Values

The following table describes the values of this property.

Value Description
color Specifies the background color. Look at CSS Color Values for the list of possible color values.
transparent Sets the background-color to transparent i.e. content and background of the element behind the element with transparent background will be visible through. This is default.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element background-color property.

Browser Compatibility

The background-color property is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 4+
  • Apple Safari 1+
  • Opera 3.5+

Further Reading

See tutorial on: CSS Background, CSS3 Background.

Related properties: background, background-attachment, background-clip, background-image, background-origin, background-position, background-repeat, background-size.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties