Categories
Background CSS

CSS background shorthand property

The background shorthand property is a method to specify the values of multiple CSS background properties all together. Shorthand properties is a CSS property that allow you set all values together. Using a shorthand property, you can write more accute style sheets.

Here are the eight background properties that can be declared as the background property:

background-image
background-position
background-size
background-repeat
background-attachment
background-origin
background-clip
background-color

Here is the syntax of the background property(shorthand):

background: [background-image] [background-position] / [background-size] [background-repeat] [background-attachment] [background-origin] [background-clip] [background-color];
Each property value is separated by at least one spacing character.

When specifying a background-size value, it must immediately follow the background-position value seperated with a slash (/)(e.g. top left/cover).

The following are the default values of each background properties

background-position: 0% 0%;
 background-size: auto;
 background-repeat: repeat;
 background-attachment: scroll; 
 background-origin: padding-box;
 background-clip: border-box;
 background-color: transparent;

Leave a Reply

Your email address will not be published. Required fields are marked *