All Tech Tips

background-attachment Attribute | backgroundAttachment Property

Sets or retrieves how the background image is attached to the object within the document.

Syntax

HTML { background-attachment : sAttachment }
Scriptingobject.style.backgroundAttachment [ = sAttachment ]

Possible Values

sAttachmentString that specifies or receives one of the following values.
scrollDefault. Background image scrolls with the object as the document is scrolled.
fixedBackground image stays fixed within the viewable area of the object.

The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of scroll. The Cascading Style Sheets (CSS) attribute is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. .

Remarks

This property can be set with the other background properties by using the background composite property.

Microsoft Internet Explorer 3.0 supports the background-attachment attribute, but only when it's set by using the background attribute.

Examples

The following examples use the background-attachment attribute and the backgroundAttachment 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">

This example uses inline scripting to set the background to fixed.

<BODY ID="oBdy" background="marble05.jpg"
onload="oBdy.style.backgroundAttachment = 'fixed'">

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, currentStyle, CUSTOM, DD, defaults, DFN, DIR, 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, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, OPTION, P, PLAINTEXT, PRE, runtimeStyle, S, SAMP, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP


Copyright © 2006 alltechtips.com. All rights reserved.

This website and the materials and information you find on this website are provided "as is", without warranty of any kind, either express or implied, including without limitation any warranty for information, services, or products provided through or in connection with the service and any implied warranties of merchantability, fitness for a particular purpose, expectation of privacy or non-infringement.