CSS Background Attachment

« Previous Tutorial Next Tutorial »

The background-attachment Property

The background-attachment property is used to fix or scroll the background image along with the text and other content displayed on it.

The background-attachment property takes either of the two values describes in the table given below:

Value Description
fixed If the value is set to fixed, the background image does not move with the text when the Web page is scrolled.
scroll If the value is set to scroll, the background image scrolls along with the text written over it. The default value of the background-attachment property is scroll.

The following code fragment shows how to use the background-attachment property:

   background-image: url('myimage.gif');
   background-attachment: scroll;

CSS Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.