CSS/Properties/background

From W3C Wiki
Jump to: navigation, search

background

The background property is a shorthand property for setting the individual background properties (i.e., 'background-color', 'background-image', 'background-repeat', 'background-attachment' and 'background-position') at the same place in the style sheet.

Description

Values [<'background-color'> || <'background-image'> || <'background-repeat'> || <'background-attachment'> || <'background-position'>] | inherit
Initial value see individual properties
Applies to All elements
Inherited No


Point, Note

  • Given a valid declaration, the 'background' property first sets all the individual background properties to their initial values, then assigns explicit values given in the declaration.


Values

See individual properties.


Example

Example A

[style.css]

 body {
   background: url("bg.png") right bottom no-repeat fixed;
 }

[index.html]

  <body>
    <p>This is a paragraph</p>
  </body>

Csslist2 background-position.png

CSS Reference

The CSS specification defines the background-attachment property in 14.2.1 Background properties.