You can group selectors
as well as declarations. Separate grouped selectors with commas rather than semicolons. For example:
h1, h2, p, em {
color:green;
text-align:left;
}
210
Designing and Crafting Core Pages Part II
Inheritance of properties
CSS rules can also be applied to more than one tag through inheritance. The HTML tags enclosed within
the CSS selector can inherit most, but not all, CSS declarations. Suppose you set all
tags to the color
red. Any tags included within a
...
tag pair then inherit that property and are also colored red.
Inheritance is also at work within HTML tags that involve a parent-child relationship, such as a list.
Whether numbered (ordered,
) or bulleted (unordered, ), a list comprises any number of list
items, designated by - tags. Each list item is considered a child of the parent tag,
or . Look
at the following example:
ol {
color:#FF0000;
}
ul {
color:#0000FF;
}
Using the preceding example, all ordered list items appear in red (#FF0000); all unordered list items appear
in blue (#0000FF). One major benefit to this parent-child relationship is that you can change the font for an
entire page with one CSS rule. The following statement accomplishes this change:
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
The change is possible in the previous example because the tag is considered the parent of every
HTML element on a page.
Pages:
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464