The CSS reference

"background-color" - css property (v. css 1)

  • This property sets the background color of an element.
  • Initial value: transparent
  • The property is not inherited
  • HTML usage: all elements
  • Browsers that support the background-color - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Possible color values:

values Comments CSS
transparant It make the underlying colors shine through. 1
Color name HTML and CSS color specification defines 147 color names (17 standard colors plus 130 more). You find all the named color through the drop-down selection in the color picker below. 1
#value A hexadecimal value representing a color in the form of Red Green and Blue components each with a value btween 00 - FF. 1
inherit Will inherit the value from parent specification. This property value is new with CSS 2. 2
Color picker:

Selected Color:

Harmonious colors:

Property "background-color" example:

<style type="text/css">
  body {
   background-color: #0076E4;
  div {
    margin: 10% 40% 10% 40%;
    background: #ffffff  center;
    height: 60%;

<div ></div>

Javascript access:

// To SET values ([o] is the target object)
[o].style.backgroundColor="background-color value"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:;
var value=cStyle.backgroundColor;
/* IE and Opera will return
   a hexa-decimal string value (ex.: #FFFFFF)
   Firefox, Chrome and Safari will return
   a rgb string value (ex.: rgb(255,255,255))*/
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.