Newlogo.gif (8646 bytes)Creating style rules which work with multiple object types


If you want to apply the same style rule to a number of different object (HTML tag) types, there's no need to repeat the rule for each type. Instead, just list the types you want the rule to apply to, separating the type names with commas. You can do this for 'all occurrences' rules and for rule classes.

This page contains this cascading style sheet:

<style>
H1, H2, H3, H4, H5, H6 {color: blue; text-decoration:underline;}
H1.special, H3.special {color:red; font-style:italic; text-decoration:none;}
</style>

The first rule is applied automatically to all occurrences of tag types H1, H2, H3, H4, H5 and H6. The second rule can be applied to H1 and H3 objects only, by adding CLASS="special" to the HTML tags.

This is text in H1 style

This is text in H2 style

This is text in H3 style

This is text in H4 style

This is text in H5 style
This is text in H6 style

This is text in H1 style, modified by the 'special' class created for H1 and H3 styles

This is text in H3 style, modified by the 'special' class created for H1 and H3 styles


Back to Menu