background-attachment

Browser Internet Explorer Netscape Opera Safari Firefox
Version 5.5 6.0 7.0 8.0 8.0 9.0 7.0 8.0 9.2 9.5 1.3 2.0 3.1 1.5 2.0 3.0
Supported Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

Short information
CSS CSS1
Default value scroll
Inherited No
Applied To all elements
HTML analog <body background="URL" bgproperties="fixed">
Reference to specification http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment

Description
The parameter “background-attachment” allows to set whether the background image will scroll with element content. You can either fix the image and make it static or move it with a document.

Syntax

background-attachment: fixed | scroll

Arguments
“fixed” Makes background image of the element static.
“scroll” Allows to move background with contents.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>background-attachment</title>
  <style type="text/css">
   BODY {
    background-image: url('images/sample.gif'); /* Path to the background image */
    background-attachment: fixed; /* Fix the background of the web page */
   }
  </style>
 </head>
 <body>
  <table>
   <tr>
    <td style="height:2000px">
      Example of the text
    </td>
   </tr>
  </table>
 </body>
</html>

Object model

[window.]document.getElementById("elementID").style.backgroundAttachment

Remark
If background is installed for layer, in this case the parameter “background-attachment” does not function in browsers, such as Opera and Firefox. The background image remains fixed in any case.