Property Description
The background shorthand property sets all of the background properties in one declaration and is composed of the background-color
, background-position
, background-size
, background-repeat
, background-origin
, background-clip
, background-attachment
, and background-image
.
This property has the following syntax:
background: color position size repeat origin clip attachment image|initial|inherit;
Note: Any values not specified are set to their default properties.
Property Values
Value | Description | Version |
---|---|---|
color | Sets the background color to be used. See background-color for possible values |
1 |
position | Sets the position of the background image. See background-position for possible values |
1 |
size | Sets the size of the background images. See background-size for possible values |
3 |
repeat | Sets how to repeat the background image. See background-repeat for possible values |
1 |
origin | Sets the positioning areas for the background image. See background-origin for possible values |
3 |
clip | Sets the painting areas for the background background image. See background-clip for possible values |
3 |
attachment | Sets whether a background image is fixed or scrolls with the rest of the page. See background-attachment for possible values |
1 |
image | Sets the background image to be used. See background-image for possible values |
1 |
initial | Specifies that the value of the property should be set to the default value | 3 |
inherit | Specifies that the value of the property should be inherited from the parent element | 2 |
Examples
This example shows how to specify several of the background properties in one declaration.
body {
background: #00ff00 url('bg-image.gif') no-repeat fixed center;
}
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
1.0 | 1.0 | 4.0 | 1.0 | 3.5 |
Miscellaneous Information
Inherited: | No |
---|---|
Defined In: | CSS1 + new properties in CSS3 |
Default Value: | see individual properties |