CSS backgroundProperty
Example
Set multiple background images (and specify their positions) in a div element.
Try it Yourself »
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
| Property | |||||
|---|---|---|---|---|---|
| background | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
All major browsers support the background property.
NoteIE8 and earlier versions do not support multiple background images for one element.
NoteIE7 and earlier versions do not support the value "inherit". IE8 requires a definition.!DOCTYPEIE9 supports "inherit".
Tag definition and usage instructions
The background shorthand property can set all background properties in one declaration.
Can be setofPropertyseparatelyYes:background-color、background-position、background-size、background-repeat、background-origin、background-clip、background-attachment and background-image。
Values are separated by spaces, in no particular order. Only some of the values can be set, for examplebackground:#FF0000 URL(smiley.gif);is allowed.
| Default Value: | See individual attributes |
|---|---|
| Inherited: | no |
| version: | New properties in CSS1+ and CSS3. |
| JavaScript Syntax: | object object.style.background="red url(smiley.gif) top left no-repeat" |
Syntax
| Value | Description | CSS |
|---|---|---|
| background-color | Specifies the background color to be used | 1 |
| background-position | Specifies the position of the background image | 1 |
| background-size | Specifies the size of the background image | 3 |
| background-repeat | Specifies how to repeat the background image | 1 |
| background-origin | Specifies the positioning area of the background image | 3 |
| background-clip | Specifies the painting area of the background image | 3 |
| background-attachment | Sets whether a background image is fixed or scrolls with the rest of the page. | 1 |
| background-image | Specifies one or more background images to use. | 1 |
Related Articles
CSS Tutorial:CSS Backgrounds
CSS3 Tutorial:CSS3 Backgrounds
other extensions