CSS background-attachment

CSS background-attachment is used to define whether an HTML image used as a background is fixed or scroll within the block. CSS background image will give the image as a background with the block.

The syntax for CSS background-attachment is:

For Example:

Output

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

CSS background-attachment values list

The values and description of this property is used to specify the background-attachment inside web document. You should also see CSS background-attachment.

Sr. No.valueDescription
1fixedUsed to make background image fixed with the block.
2scrollUsed to make background image fixed with the block and will not scoll.
3localUsed to give color name. The value for this can be red, blue etc.
4transparentUsed to make a transparent color of an HTML element content. The value for this is transparent.
5initialUsed to define as the property initial value.
6inheritUsed to define the computed value of property on the elements parent.
7unsetUsed to set all the properties to their parent value if inheritable.

scroll CSS background-attachemnt

In this example we will use CSS background-image with scroll CSS background-attachement.

Output

This is the HTML paragraph inside the div. The div contains some background image. This background image has scroll attachment.