1. Home
  2. Computing & Technology
  3. Web Design / HTML

background-color

By Jennifer Kyrnin, About.com

background-color Description:

The background-color property defines the background color of the element.

background-color in CSS Versions:

background-color Syntax:

background-color: <color> | transparent | inherit

  • <color>
    The color of the background.
  • transparent
    Takes the same color as the element below it.
  • inherit
    The element should have the same background-color setting as the parent.

background-color Initial Value:

transparent

background-color Applies To:

All elements.

background-color Inheritance:

This property is not inherited.

background-color Browser Support:

background-color Examples:

Standard background-color property

<p style="background-color : #ccc;">
This paragraph has a grey background.
</p>

transparent background

<p style="background-color : transparent;">
This paragraph will have the same background color as whatever is below it in z-index.
</p>

background-color Special Notes:

  • background-color can be defined as hexadecimal (#ff0000), RGB (rgb(255,0,0)), or background-color names (red).
  • Be careful using the "transparent" value with Netscape - it sometimes translates that as black (#000 or rgb(0%,0%,0%)).
  • It's a good idea to style the color of your text when you use a dark background color.

More background-color Information:

Return to the Style Library

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. CSS
  5. Style Properties
  6. CSS Style Property: background-color

©2008 About.com, a part of The New York Times Company.

All rights reserved.