The CSS reference

"background-attachment" - css property (v. css 1)

  • If a background image is specified, the value of 'background-attachment' determines if it is fixed with regard to the canvas or if it scrolls along with the content.
  • Initial value: scroll
  • The property is not inherited
  • HTML usage: all elements
  • The value must be scroll or fixed
  • The inherit value, which is new with CSS 2 will inherit the attachment from parent specification.
  • Browsers that support the background-attachment - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Property "background-attachment" example:

<style type="text/css">
  body {
    background: #cdcdcd url(images/Trophy.png);
    background-repeat: repeat-y;
    background-attachment: scroll;
    height: 200%;
  div {
    margin: 10% 40% 10% 40%;
    background: #ffffff no-repeat center;
    height: 90%;
    background-image: inherit;
    background-attachment: fixed;
<div ></div>

Javascript access:

// To SET values ([o] is the target object) 
[o].style.backgroundAttachment="background-attachment value"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null);
// To GET the property value:
var value=cStyle.backgroundAttachment;
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.