CSS background

CSS background is used to define different background properties in single setting. background can be used for the CSS background-image, can be used for background-position and all other properties.

The syntax for background is:

For Example:

Output

This is the HTML paragraph inside the div. The div contains some background image. This background image has fixed attachment. The background showing the nature image.

CSS background values list

The values and description of this property is used to specify the background property in single setting.

Sr. No.valueDescription
1url(image url location)Used to make background image. The value for this is the location of the image. See background-image property for this
2noneUsed to make no background image.
3repeat styleUsed to make background image repeat or not repeat. The value for this is repeat or no-repeat. See background-repeat property for this
4sizeUsed to set background image size. See background-size property for this
5attachmentUsed to make background image attachment. To know more detail, See background-attachment property for this.
6colorUsed to give background color. See background-color property for this
7initialUsed to define as the property initial value.
8inheritUsed to define the computed value of property on the elements parent.
9unsetUsed to set all the properties to their parent value if inheritable.

CSS background with position center

In this example we will use background-image with center position.

Output

This is the HTML paragraph inside the div. The div contains some background image. This background image has fixed attachment. The background showing the nature image.