CSS background-attachment property
CSS background-attachment property
Description
background-attachment determines the tiling context and scrolling state of a background image.
Possible values
- scroll – A background image set to scroll will scroll with the rest of the document.
-
fixed – Background https://coder-cafe.com/wp-content/uploads/2025/09/images set to fixed will remain in place as the rest of the document scrolls.
Applies to
All HTML elements.
DOM syntax
object.style.backgroundAttachment = scroll | fixed;
Example
<html>
<head>
</head>
<body>
<p style = "background-image:url(https://geek-docs.com/static/https://coder-cafe.com/wp-content/uploads/2025/09/logo.png);
background-attachment:scroll; background-attachment:scroll;
background-repeat: no-repeat;
background-attachment: fixed;">
This parapgraph has scrolling background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
</p>
</body>
</html>
It will produce the following results –