Properties can also be applied to multiple tags by grouping the tags in the selector statement separated by commas.
Example Headings Rule
h1, h2 { color: #ff0000 }
The rule above sets all h1 and h2 headings to red.
Inheritance
When tags are enclosed within other tags then they inherit the style of the enclosing tag. This is useful since it means that styles needn't be specified for all possible tags - only where exceptions are required.
Example of a Body Style Rule
body { color: #000000; font-size: 12px }
The rule above sets the font colour and size for all elements that body encloses but if we wanted text within tables to appear differently then we can add another rule.
The rules above set the font colour and size for all elements that body encloses except tables which are set to a different font colour and size.
Contextual Selectors
Inheritance allows styles to be applied depending on the context. So for example we may wish a particular style to be applied to unordered list items generally but differently when they occur within tables.
Example of a Contextual Selector
body { color: #000000; font-size: 12px }
table ol { color: #0000ff; font-size: 10px }
The rules above set the font colour and size for all elements that body encloses, including unordered lists. However any unordered lists that are enclosed by tables are set to a different font colour and size.
Important: The selector tags must be separated by white space as opposed to commas as was used to group tags.