Prev | Current Page 42 | Next

Charles Wyke-Smith

"Stylin' with CSS: A Designer's Guide 2nd Edition"

An
element type, such as p, can be styled one way within one div and
another way within another div. Let??™s start understanding how this
works by looking at document hierarchy.
The default blue border around the
header graphic indicates that the
image is clickable (the img tag is
enclosed in an a tag), and this rather
ugly border can easily be removed
with CSS, as we will see later.
Class attributes are similar to IDs
in as much as they can be used to
identify groups of tags, but while a
class can appear many times within
a page, an ID can appear only once.
We will learn about the correct uses
of classes and IDs in the next chapter.
Also see the sidebar ???Naming
Classes and IDs.???
STYLIN??™ WITH CSS - CHAPTER 1 24
Naming Classes and IDs
IDs and class attributes are identi?¬? ers you can add to your tags. You can add a class or an ID attribute to any tag,
although most commonly, you add them to block-level elements. IDs and classes help you accurately target your CSS to
a speci?¬? c element or set of elements. I get into the uses for (and differences between) IDs and classes later, but for now,
it??™s helpful to know that an attribute value must be a single word, although you can make compound words that the
browser sees as single words using underscores, such as class="navigation_links".
Because the browser can misinterpret attribute names made of bizarre strings of characters, my advice is to start the
word with a letter, not a number or a symbol.


Pages:
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54