Name

background-color — NN 4 IE 4 CSS 1

Synopsis

Inherited: No

Sets the background color for the element. Although it may appear as though a nested element’s background-color attribute is inherited, in truth the initial value is transparent, which lets the next outermost colored element show through whitespace of the current element.

CSS Syntax

background-color: color

JavaScript Equivalent

backgroundColor

Value

Any valid color specification (see description at beginning of the chapter) or transparent.

Initial Value

transparent

Example

.highlighter {background-color: yellow}

Applies To

All elements.

Object Model Reference

IE

[window.]document.all. elementID .style.backgroundColor

Get Dynamic HTML: The Definitive Reference 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.