Graphics Programs Reference
Figure 2-9: Attractive links in the header.
h at's all it takes. So that's a rationale for making most or all of your labels class es.
Another rationale is that you can never be quite certain when a label will shit from being
unique to being repetitive. header is actually a great example, because it's possible a page
could have multiple headers. If that seems weird, think of a news site or other portal. Every
subsection and sidebar box could have its own little header—and, for that matter, footer.
Classing them all consistently makes a lot of sense.
Now, you might well argue that those aren't real headers and footers like those on a page—
they're headlines or additional information or what-have-you. h at's a semantic argument,
and not one that can be dei nitively resolved. What you call a topline, I might call a header.
h e point is that a word you use to label a unique feature of your page might one day not be
unique. h e best way to future-proof yourself against that happening is to use all class es in
the i rst place.
So is there any point to using id ? Of course. h ere are situations where you can be certain a
given element will be unique within the page, and will never be duplicated. h ere are also
situations where you want the increased specii city an id selector confers, because it lets you
trump other selectors very easily. And id s can be crucial for scripting, link targeting, and
other things beyond CSS. You just have to use them with a bit of care when it comes to
writing your CSS.
(h ere's also an alternate way to address IDs that doesn't carry the same concerns about
specii city with it; see “ID vs. Attribute Selector" later in this chapter.)
ID WITH CLASS
h ere may occasionally be situations where you have an element that is unique, and yet is part
of a broader class of elements. For example, suppose you have a bunch of little panels in your
site's sidebar. Each one gets a box around it, and has a certain color and font combination, but
each one is also unique in its own way, such as each getting a dif erent background image.
Search WWH ::