untitled

(John Hannent) #1

Chapter 6


Chapter 6: Managing Details in Style Sheets ..............................................................


In This Chapter


Describing units, percentages, and lengths


Adding color to your text


Coloring the background


A


mong the various features of CSS that Web designers appreciate is the
fine control it gives you over such details as color, text spacing, posi-
tioning, and size of various elements. Plain HTML comes to seem rather
crude and clumsy after you’ve had some experience playing around with all
the freedom that CSS gives you. With CSS, you decide just how things should
look on your pages.

Specifying Size and Position ......................................................................


In a CSS style definition (or rule), you can describe positions and sizes in
many ways, using may different units of measurement. You can often choose
whatever unit you want, although certain specific kinds of measurements
work best in certain situations.

For example, many designers working with paper and ink are used to specify-
ing typefaces in points. A point is an absolute length: 1/72 of an inch. Using
absolute type size specs for a magazine or book works just fine — after all,
the user cannot shrink, stretch, or change the aspect ratio of a page in a
book. (Aspect ratio is the ratio between height and width.) Browsers, though,
can be resized at will. If you drag one side of a browser, you’re changing it,
making it thinner or fatter. In other words, your changing its shape, its aspect
ratio, from, say, a square to a rectangle.

For fonts displayed in a browser, a relative unit of measurement is superior
to the traditional points. Unlike absolute measurements such as points or
inches, a relative unit scales with font sizes. As a result, you get more pre-
dictable results in Web pages with relative units of measurements specifying
type size. One of the most useful relative units of measurements for a Web
designer is the em— more on that later in this chapter. Although the em is
Free download pdf