O'Reilly logo

HTML, XHTML, and CSS: Your visual blueprint™ for designing effective Web pages by Rob Huddleston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. APPLYING MORE FORMATTING TO YOUR PAGE

Add Background Colors to Elements on a Page

Using CSS, you can set the background color of any element on the page by using the background-color property and an appropriate color value. Just as with color, background-color can take as its value a named color, an RGB (red, green, blue) value, or a hexadecimal value.

h1 { background-color: #3F6; }

By default, background-color is set to none, which allows the color of the parent element to be seen through the current element. CSS also supports a value of transparent, which gives the same result as none. Either of these values can be used to override a background color that is being inherited from a parent element.

Setting the background-color of the

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required