You are here: Reference > CSS > properties > background-color

background-color property

Browser support:
Specifies the color to use for the background of the object.
With the background-color property you can set the background color of an element and you can also set the element's background to transparent.
Transparency is allowed by default for frame elements (frame and iframe) in all commonly used browsers, except in Internet Explorer before version 9. In Internet Explorer before version 9, use ALLOWTRANSPARENCY attribute to allow a frame element to be transparent.
JavaScript page for this property: backgroundColor. You can find other example(s) there.

Possible values:

 One of the following values: 
color
Color of the background. For the supported color values, see the colors page.
inherit
Takes the value of this property from the computed style of the parent element.
transparent
Default. Underlying content will shine through.
Default: transparent.

Example HTML code 1:

This example illustrates the use of the background-color property:
<head>
    <style>
        .example {
            background-color: #FF0000;
            width: 300px;
            height: 200px;
            overflow: scroll;
        }
    </style>
</head>
<body>
    <div class="example">
        Some content ..... <br /> ..... <br /> ..... <br />
        Some content ..... <br /> ..... <br /> ..... <br />
        Some content ..... <br /> ..... <br /> ..... <br />
        Some content ..... <br /> ..... <br /> ..... <br />
    </div>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content