SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 457 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"

alert rule would be applied and the

tag would appear red. The reason
this is true is because the .alert selector is more specific than the

tag selector. The W3C CSS specification
(no relation) provides a different weight for each kind of selector.
A rule??™s specificity is noted with four comma-separated values. For example, the specificity for the


rule is
0,0,0,1
because there is one tag element in the selector. Whereas the specificity for the .alert rule is
0,0,1,0
because there is one class element in the selector. Any positive value in the second-to-last column outweighs
any value in the last column.
The formula for creating specificity is as follows:
Total inline styles, total ID selectors, total class and pseudo-class
selectors, total tag elements
Inline styles are the most specific??”and the most rarely used these days??”so they trump any other type of
selector. If two rules have the same specificity and are applied to the same selection, the rule that comes
later in the style sheet??”because it is physically closer to the code??”wins.
How styles are applied
CSS applies style formatting to your page in one of three ways:
n Via an external, linked style sheet
n Via an embedded styles
n Via inline style rules
External style sheets
An external style sheet is a file containing the CSS rules; it links one or more Web pages.


Pages:
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469