backgroundImage property

Specifies the background image or images of the object.

 

Syntax

Integer value = object.put_backgroundImage( v);Integer value = object.get_backgroundImage(* sLocation);

Property values

Type: BSTR

none

Initial value. Color of the next parent through which the background is visible.

url(sUrl)

Location of the background image(s), where "sUrl" is an absolute or relative URL.

String format

none | <image> | <function> [ , none | <image> | <function> ]*

CSS information

Applies To All elements
Media visual
Inherited no
Initial Value none

Standards information

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 IHTMLRuleStyle::background composite property.

Starting in Windows Internet Explorer 9, the background of a box can have multiple layers. The number of layers is determined by the number of comma-separated values in the IHTMLCurrentStyle::backgroundImage property. Each of the images is sized, positioned, and tiled according to the corresponding value in the other background properties (IHTMLCurrentStyle::backgroundAttachment, IHTMLCSSStyleDeclaration::backgroundClip, IHTMLCSSStyleDeclaration::backgroundOrigin, IHTMLRuleStyle::backgroundPosition, IHTMLCurrentStyle::backgroundRepeat, and IHTMLCSSStyleDeclaration::backgroundSize). The first image in the list is the layer closest to the user, the next one is painted behind the first, and so on.

The background of a box can have multiple layers. The number of layers is determined by the number of comma-separated values in the IHTMLCurrentStyle::backgroundImage property. Each of the images is sized, positioned, and tiled according to the corresponding value in the other background properties (IHTMLCurrentStyle::backgroundAttachment, IHTMLCSSStyleDeclaration::backgroundClip, IHTMLCSSStyleDeclaration::backgroundOrigin, IHTMLRuleStyle::backgroundPosition, IHTMLCurrentStyle::backgroundRepeat, and IHTMLCSSStyleDeclaration::backgroundSize). The first image in the list is the layer closest to the user, the next one is painted behind the first, and so on.

As of Internet Explorer for Windows Phone 8.1 Update, Internet Explorer for Windows Phone supports "-webkit-background-image" as an alias for this property.

Examples

This example uses IHTMLCurrentStyle::backgroundImage and IHTMLCurrentStyle::backgroundColor to create three div objects with the same width and height but different background images and colors.

div {
  width: 150px;
  height: 150px;
  background-repeat: no-repeat;
  background-position: 50% 50%;
  float: left;
  margin-right: 10px;
}
.circle {
  background-color: aqua;
  background-image: url(circle.png);
}
.square {
  background-color: aquamarine;
  background-image: url(square.png);
}
.triangle {
  background-color: bisque;
  background-image: url(triangle.png);
}
<body>
   <div class="circle"></div>
   <div class="square"></div>
   <div class="triangle"></div>
</body>

The following image shows the result:

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll