HTML and CSS Reference
In-Depth Information
T IP The support site http://htmlref.com has this reference online and may have updates or fixes to
this information.
background
This property sets in a shorthand form any or all background properties.
Syntax
background: background-color background-image background-repeat
background-attachment background-position;
Property order should not matter, and any properties not specified use their default values.
Examples
body {background: white url(picture.gif) repeat-y center;}
.red {background: #ff0000;}
#div1 {background: white url(logo.gif) no-repeat fixed 10px 10px;}
Compatability
CSS 1, 2, 3 IE 4+ Netscape 4 (buggy), 6+, Firefox 1+ Opera 4+, Safari 1+
Notes
• As with all shorthand forms, document authors should experiment with individual
background-related property values before adopting a short form.
• Under the emerging CSS3 specification, it is possible to specify multiple files for a
background and separate each with a comma. For example,
body {background: white url(donkey.gif) top left no-repeat,
url(elephant.gif) bottom right no-repeat;}
would put a background image in the top-left and bottom-right areas of the body,
respectively. Support is limited, though Safari 1.3+ browsers support most CSS3
background features.
background-attachment
This property sets the background image to scroll or not to scroll with its associated element's
content. The default value is scroll , which sets the background to scroll with the associated
content, typically text. The alternate value, fixed , is intended to make the background static
while associated content such as text scrolls over the background. A value of inherit applies
the value of this property from a containing parent element.
Syntax
background-attachment: scroll | fixed | inherit
Examples
body {background-image: url(tile.gif); background-attachment: scroll;}
#logo {background-image: url(logo.gif); background-attachment: fixed;}
Search WWH ::




Custom Search