style.backgroundColor (Property)

A color of the styled object's background.


CSS level - 1
DOM level - 2
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Opera - 5.0
Property/method value type:String primitive
JavaScript syntax:-myStyle.backgroundColor
CSS syntax:background-color: acolor
HTML syntax:<BODY BGCOLOR="...">
Argument list:acolorA valid color specifier

This background color is applied to the element before any background image is drawn. You can define both a background image and a background color. If you do, and if the background image contains any pixels that are set to a transparent color, then the background color will show through.

There are several ways in which you can access the background color of a document or element. Depending on how you do this, you may affect the entire document or just a part of it.

Example code:

   <DIV ID="ONE" STYLE="background-color:RED">
   The DIV block ONE
   <DIV ID="TWO" STYLE="background-color:BLUE">
   The DIV block TWO
   <INPUT TYPE="button" VALUE="CLICK ME" onClick="clickMe()">
   function clickMe()
      myStyle1 =;
      myStyle2 =;
 = myStyle2; = myStyle1;

See also:color names, color value, Document.bgColor, JSSTag.backgroundColor, rgb(), style.background