Sets or retrieves how the background image is attached to the object within the document.
Syntax
{ background-attachment: sAttachment }
Possible values
sAttachment
String that specifies or receives one of the following values:
scroll | Default. Background image scrolls with the object as the document is scrolled. |
fixed | Background image stays fixed within the viewable area of the object. |
The property has a default value of scroll. It is not inherited.
Remarks
This property can be set with the other background properties by using the background composite property.
Examples
The following example uses the background-attachment property to set the background to fixed, so that the background does not scroll with the text. This example uses an inline style sheet to set the background to fixed:
![]() | |
---|---|
<style > body { background-attachment: fixed; } </style> </head><body background="some.jpg"> |
Standards information
This property is defined in Cascading Style Sheets (CSS), Level 1 (CSS1).
Applies to
A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CUSTOM, DD, DEFAULTS, DFN, DIV, DL, DT, EM, FIELDSET, FORM, HN, HTML, I, IFRAME, IMG, INPUT TYPE=BUTTON, INPUT TYPE=CHECKBOX, INPUT TYPE=FILE, INPUT TYPE=IMAGE, INPUT TYPE=PASSWORD, INPUT TYPE=RADIO, INPUT TYPE=RESET, INPUT TYPE=SUBMIT, INPUT TYPE=TEXT, LI, OL, OPTION, P, S, SPAN, SUB, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP