Hour Ten: Backgrounds and Background Colors
In Hour 2, "Getting Started with CSS," you learned how to use the background-color property to change the appearance of HTML elements. Background colors can be used to good effect in Web design to group related items together or to highlight important parts of the page. In addition to pure colors, you can also use images as backgrounds for the whole page or for any element on the page.
In this hour, you'll learn
- More using about the background-color property
- How to use background and foreground colors together effectively
- How to set a background image and how to control the display of that background
- Which types of images you can use as backgrounds
Sample Code
You can download the sample code from each hour as one package or individual files.
- Download all [3K tar.gz file]
- Starfield graphic [GIF format]
- Listing 10.1 [HTML]
- Figure 10.2 style sheet [CSS]
- Listing 10.1 with figure 10.2 style sheet [HTML]
- Figure 10.3 style sheet [CSS]
- Listing 10.1 with figure 10.3 style sheet [HTML]
- Figure 10.4 style sheet [CSS]
- Listing 10.1 with figure 10.4 style sheet [HTML]
- Listing 10.2 [CSS]
- Listing 10.1 with style sheet 10.2 [HTML]
- Listing 10.3 [CSS]
- Listing 10.1 with style sheet 10.3 [HTML]
- Listing 10.4 [CSS]
- Listing 10.1 with style sheet 10.4 [HTML]
- Listing 10.5 [CSS]
- Listing 10.1 with style sheet 10.5 [HTML]
- Listing 10.6 [CSS]
- Listing 10.1 with style sheet 10.6 [HTML]
Web Links
These are the links presented in this hour, given here for easy reference.
- Visibone Web Site for color charts and more
Updates and Errata
The file names given in the source listings for Listing 10.5 and 10.6 are off by one; for example, Listing 10.5 has the comment /* stars-10.6.css */. Also, to view the fixed background, you should load the URL http://www.cssin24hours.com/10/anthem-10.6.html, not anthem-10.7.html.