Chapter 33. Colors and Backgrounds
IN THIS CHAPTER
The previous chapter covered the box formatting model of CSS. You learned how you can manipulate an element's containing box to better format your HTML documents. This chapter continues the discussion, covering element foreground and background colors, and the use of images for element backgrounds.
Most elements in an HTML document have two color properties, a foreground property and a background property. Both of these properties can be controlled using CSS styles. The following sections discuss both types of color properties.
An element's foreground color is typically used on the visible portion of that element. In most cases, the visible foreground portion of an element is text, but there are instances where the foreground contains other, nontextual components. You can control the foreground color of an element using the CSS
color property, which has the following format:
As with other properties that use color values, the value of the
color property can be expressed using one of three methods:
Predefined color keywords (such as
blue, red, black, or
Hexadecimal color values in
#FF00FFfor dark purple, and so on)
An RGB value using the
For example, the following style defines a class of the paragraph element, which will be rendered with a red ...