background-image

Browser Internet Explorer Netscape Opera Safari Firefox
Version 5.5 6.0 7.0 8.0 8.0 9.0 7.0 8.0 9.2 9.5 1.3 2.0 3.1 1.5 2.0 3.0
Supported Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

Short information
CSS CSS1
Default value none
Inherited No
Applied To all elements
HTML analog <body background="URL">
Reference to specification http://www.w3.org/TR/CSS21/colors.html#propdef-background-image

Description
It determines background image for the element. If the background color is specified for the element at the same time it will be shown while the background image will have been downloaded fully. The same will happen if the image is inaccessible or their demonstration in the browser is switched off. When there are transparent areas in the image you can see the background color through them.

Syntax

background-image: url(path to the file) | none

Arguments
Path to the graphic file is a value which is indicated inside the construction “url()”.You can write the file path either in quotation marks (double or single) or without them. The argument can have the value “none” if the background image is not necessary.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
 <title>background-image</title>
 <style type="text/css">
  BODY {
   background-image: url(images/bg.jpg); /* Path to the background image */
   background-color: #c7b29a; /* Background color */
  }
 </style>
 </head>
 <body>
  <p>...</p>
 </body>
</html>

Object model

[window.]document.getElementById("elementID").style.backgroundImage