Entry
Can I apply the same style to different elements?
Jun 13th, 2000 05:29
Rey Nuņez, http://www.w3.org/TR/REC-CSS2/selector.html#grouping
A single declaration may be set for a comma-separated list of multiple
selectors that will share common style properties, as in:
h1, h2, h3, h4 {
font-family:"Verdana, sans-serif";
text-align:right; padding-right:10px}
And due to the nature of cascading styles, other declarations may be
set to add to or differentiate earlier styles that have been commonly
applied. For instance, the example above applies the shared properties,
but can further be differentiated by adding the following declarations
in the same style sheet:
h1 {font-size:18pt; color:#ffc}
h2 {font-size:16pt; color:#963}
h3 {font-size:14pt; color:#369}
h4 {font-size:13pt; color:#663}
which differentiates the font sizes and colors for the defined
selectors.
Note that browsers are built with default style sheets, meaning that if
we do not specify distinct properties (as in our example above), the
browser renders the headers in the default font sizes and colors. The
browser applies style properties that have been declared, and uses its
default settings for the rest.