HTML and CSS Reference
Table 8-1. CSS Background Properties
Sets the background color of an element.
Sets the background image(s) of an element. IE 6-8
allow only one image.
Controls how background images repeat if smaller
than the element. By default, images tile horizontally
Determines whether the background image remains
in a fixed position or scrolls with the page.
Determines the background image's horizontal and
vertical position. The default is the top left of the
Determines the point from which background-
position is measured. Not supported by IE 6-8.
Determines the area covered by the background.
Not supported by IE 6-8.
Controls the size of background images. Not
supported by IE 6-8.
See individual properties
Shorthand property for setting all background
properties in a single declaration.
Apart from background-color , all the individual properties are concerned with background images. The
background properties are not inherited, but the background of a parent element remains visible because
the default value of background-color is transparent .
Changing the Background Color of an Element
As you might expect, the background-color property takes as its value a color, which can be expressed in any of
the ways described in “Setting Color Values” in Chapter 3 , namely:
A 3- or 6-digit hexadecimal number
A color keyword
A color with alpha transparency specified as an
rgba() or hsla() value
Hexadecimal numbers, color keywords, and rgb() values are supported by all browsers. So, it's a good idea
to choose one of them unless you want to use a background color with alpha transparency. For example, the
background color for the <body> in background_alpha.html in the ch08 folder (see Figure 8-1 ) is defined using
hexadecimal notation like this: