This background property is a shorthand property for setting the color, position, size, repeat, clip, origin, attachment, and image of the element.
The background- properties provide fundamental styles to an element, such as color, image, and position. CSS3 adds more properties for handling backgrounds, including properties that improve the mobile web experience. Many CSS background properties can be set, at the same time, with this background property.
Overview table[[Initial value::see individual properties: * background-color * background-position * background-size * background-repeat * background-attachment * background-clip * background-origin * background-image]]
background
background: <attachment>
background: <bg-image>
background: <box>{1,2}
background: <color>
background: <position> [ / <bg-size> ]?
background: <repeat-style>
none
.
repeat
.
scroll
.
For background-clip, valid values are those available to background-clip property. The default value is border-box
. For background-origin, valid values are those available to background-origin property. The default value is padding-box
.
transparent
.
The background property is set to the color #f06 on the p element.
p {
background: #f06;
}
Only one background property is set on the body. Many individual properties have been specified for the p element, including a background image that only shows up on the p element.
body {
background: #90ee90;
font-family: 'Bitter';
}
p { background: url(/logo/wplogo_transparent_xlg.png)
40% / 20em
#ffffe0
round
fixed
border-box;
}
Usage
The background property is a shorthand property that can set almost all of the background- properties. The specification has examples of how to use the shorthand property and what that usage translates to.
Notes
The background of the root element becomes the background of the canvas and extends to cover the entire canvas, but only for that element alone. For an example, see [1].
Related specificationsbackground
background
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4