Prev | Current Page 82 | Next

Charles Wyke-Smith

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

If a matched property is de?¬? ned again further down the
sequence, the browser updates the value and does this repeatedly, if
necessary, until all ?¬? ve possible locations of properties for each tag
in that page have been checked. Whatever a particular property is
set to at the end of this process, that??™s how it is displayed.
In Table 2.1, we look at this process for a page with numerous p tags.
Let??™s assume, for the sake of the example, that two of those p tags
have inline styles that de?¬? ne their color as red. In this case, every p
tag text is blue, except for ones with the inline color attribute??”these
are red.
TABLE 2.1 Cascade Example
LOCATION TAG PROPERTY VALUE
Default style sheet P color black
User style sheet
Author style sheet P color blue
Author embedded styles
Author inline styles P color red
Of course, things aren??™t quite that simple. There is also the weight of
the declaration. You can de?¬? ne a rule as important, like this
p {color:red !important; font-size:12pt;}
The word !important follows a space after the style you want to
make important but before the ; (semicolon) separator.
This style de?¬? nes the text??™s red color as important, and therefore,
it displays this way, even if it is declared as a different color further
down the Cascade. Think hard and long before you force a particular
style on the user with !important rule de?¬? nition, because you may
be messing up someone??™s personal style sheet, which may be set
that way for a very good reason; be sure that it truly is important for
such a style to dominate over any other possible style for that tag.


Pages:
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94