XML technologies / CSS / Advanced websites with CSS / CSS property reference / background-image
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The property background-image assigns a background image to an HTML element. Its position and tiling can be set with the properties background-position and background-repeat.
A parent element’s background image remains visible through its descendants unless their backgrounds are overridden with their own declarations of background-color or background-image.
Inherited: no
See also: background-attachment, background-color, background-position, background-repeat
Values
A URL or none. CSS places a URL inside the tag url(); HTML-style quotation marks are not valid.
Default value: none
Compatibility
CSS version: 1
Works in all CSS-capable browsers, including Internet Explorer 4 and later and Netscape 4 and later.
Netscape 4 does not display a background image across an entire block element unless a border (border) is also defined (a border width of 0px is sufficient). Even with a visible border, a transparent gap remains between the padding and border. Netscape’s proprietary property layer-background-image can fill this gap separately with the background image.
Examples
The following rules add a background image using a relative path, an absolute path and a complete HTTP path respectively:
body {
background-image: url(../images/textur.gif);
}
body {
background-image: url(/images/textur.gif);
}
body {
background-image: url(http://www.mysite.com/images/textur.gif);
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg