background

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 Depends on arguments used
Inherited No
Applied To all elements
HTML analog <body bgcolor="color" background="URL" bgproperties="fixed">
<table | thead | tbody | tfoot | tr | th | td bgcolor="color" background="URL">
Reference to specification http://www.w3.org/TR/CSS21/colors.html#propdef-background

Description
This parameter allows to set from one to five background styles. The values may be in random order and browser defines the value fitting the attribute. If you want to learn more about the arguments, look their properties separately.

Syntax

background: background-attachment || background-color || background-image || background-position || background-repeat

Arguments
All the combinations of 5 values defining a background style in the random order are parted by the space. No argument is obligatory, so you can omit values you do not use.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!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</title>
  <style type="text/css">
   DIV {
    height: 200px; /* Block height */
    width: 200px; /* Block width */
    overflow: auto; /* Add scrolling bands */
    padding-left: 15px; /* Left indent from the text */
    background: #fc0 url(images/hand.png) repeat-y; /* Background color, 
                                                    path to the background image and 
                                                    vertical repeat of the background  */
   }
  </style>
 </head>
 <body>
 
  <div>
   Duis te feugifacilisi. Duis autem dolor in hendrerit in vulputate velit esse molestie 
   consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et 
   iusto odio dignissim qui blandit praesent luptatum zzril delenit au gue duis dolore
   te feugat nulla facilisi. Ut wisi enim ad minim veniam, quis nostrud exerci taion 
   ullamcorper suscipit lobortis nisl ut aliquip ex en commodo consequat. Duis te 
   feugifacilisi per suscipit lobortis nisl ut aliquip ex en commodo consequat.
  </div>
 </body>
</html>

The result of this example is shown below (fig.1)


Object model

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