CHAPTER 13 COLORS AND BACKGROUNDS

(Plus Even More Selectors and External Style Sheets)

IN THIS CHAPTER

Color names in CSS

Specifying RGB color values

Foreground and background colors

Pseudoclass and pseudoelement selectors

Adding tiling background images

Controlling the repeat and position of background images

External style sheets

Style sheets for print and other media

Did you happen to see the Web back in 1993? It was a fairly dreary affair back then, where every background was gray and all the text was black. Then came the Netscape Navigator browser and, with it, a handful of attributes that allowed rudimentary (but welcome) control over font colors and backgrounds. For years, we made do.

But thankfully, now we have style sheet properties that blow those old attributes out of the water. So if you happen to view the source of a web page and see attributes such as bgcolor, background, link, and vlink floating around, ignore them. They are relics of the past. Believe me, you’re much better off without them.

We’re going to cover a lot of ground in this chapter. Of course, I’ll introduce you to all of the properties for specifying colors and backgrounds. This chapter also rounds out your collection of selector types and shows you how to create an external style sheet as well as a style sheet just for print. Oh, and there will be cabbages...lots and lots of cabbages (you’ll see).

Our first order of business is to talk about the options for specifying color in CSS, including a primer ...

Get Learning Web Design, 3rd Edition 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.