Sets or retrieves the background image of the object.
Syntax
{ background-image: sLocation }
Possible values
sLocation
String that specifies or receives one of the following values:
none | Default. Color of the next parent element through which the background is visible. |
url(sUrl) | Location of the background image, where sUrl is an absolute or relative URL. |
This property has a default value of none. It is not inherited.
Remarks
The URL identifies the image file. When setting a background image, you can set a background color to use when the image is unavailable. When the image is available, it overlays the background color.
This property can be set with other background properties by using the background composite property.
Examples
The following example uses the background-image property to specify the background's image. This example uses a call to an embedded (global) style sheet to show and hide the background image:
![]() | |
---|---|
<style> .setUrl { background-image: url(sphere.jpg); } .loseUrl { background-image: url(none); } </style> </head> <body> <span style="font-size: 14;" onmouseover="this.className='setUrl'" onmouseout="this.className='loseUrl'"> . . . </span> |
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, 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, P, S, SPAN, SUB, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP