CSS Background Properties

By SlilohNo Comments
Property Description
background Sets all the background properties in one declaration
For setting all of the background properties in one property, you can use the shorthand property. That sounds repetitive as hell.
To use the shorthand property the order of the property values are:

  • background-color
  • background-image
  • background-repeat
  • background-attachment
  • background-position

It doesn’t matter if one of the property values is missing, as long as the ones that are present are in this order.

body {background:#ccc url(‘fish.gif’) repeat-y left top;}
background-attachment Sets whether a background image is fixed or scrolls with the rest of the page
background-color Sets the background color of an element
background-image Sets the background image for an element
background-position Sets the starting position of a background image
background-repeat Sets how a background image will be repeated