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

Get HTML, XHTML, and CSS: Your visual blueprint™ for designing effective Web pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.