background-image

Sets the background image of the object.

Syntax

{ background-image: sLocation }

Possible values

sLocation

String that specifies 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) Ee371196.xtlink_newWindow(en-us,Expression.40).png.

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, select, span, sub, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var, xmp

See also

Concepts

background
background-color
background-position
background-repeat

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.