background-color

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 transparent
Inherited No
Applied To all elements
HTML analog <body | table | thead | tbody | tfoot | th | td bgcolor="color">
Reference to specification http://www.w3.org/TR/CSS21/colors.html#propdef-background-color
Description
This parameter sets the background color of the element. Through this parameter doesn’t inherit its parent’s qualities it concurs with the background of the current element because the initial value of the background color is set transparent.

Syntax

background-color: color | transparent
Arguments
It is possible to make a color by 3 ways:
1. By the name.
Browsers support some colors by the names.
2. By the hexadecimal value
The numbers in hexadecimal code are used for colors specifying. This system opposite to the decimal one is based on the number 16 as you can see from its name. It uses the next symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. The numbers from 10 to 15 are substituted to the latin letters. In the decimal system the numbers after 15 are formed by integration of 2 numbers into 1. For example, number 255 fits number FF in hexadecimal system. For avoiding misunderstandings in defining the number language, the symbol # is set before the hexadecimal value, for example #666999. Each of three colors — red, green and blue can have the values from 00 to FF. Thus, color defining is divided in three components #rrggbb, where first 2 symbols mark red component of a color, 2 medium ones define green and two last ones define dark blue. It is allowed to use the abridged form like #rgb, where every symbol neededs to be doubled. So, it is necessary to consider the record #fe0 as #ffee00.
3. By RGB
It is possible to define a color using values of red, green and blue components in decimal calculation. Each value of three colors can have values from 0 to 255. It is also possible to set a color in a percentage ratio.
Also the element “transparent” determining a transparent background is available

Example

 
<!--
   BODY {
    background-color: #3366CC; /* Background color of the web page */
   } 
   H1 {
    background-color: RGB(249, 201, 16); /* Background color under the title */
   }
   P {
    background-color: maroon; /* Background color under the paragraph text */
    color: white; /* Text color */
   }
 
-->
<h1>Lorem ipsum dolor sit amet</h1>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem
  nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.
The result of this example is shown on the figure 1

Object model
[window.]document.getElementById("elementID").style.backgroundColor