1.7

Table Of Contents
Rules for HTML elements (p, table, li etc.) are general rules. Rules for classes, pseudo classes,
and elements with a certain attribute (.class, :hover, [target]) are more specific. Rules for
elements with a certain ID are even more specific. The most specific are inline styles.
Example
A more specific rule for cells in a table that has the CSS property “color: red (which colors text
in the cells red) could be, for example:
l A rule for the text color of all table cells (td elements), for example:td { color:
green; }.
l A rule for the text color of table cells with a certain class, for example.green { color:
green; }
l A rule for the text color of a table cell with a certain ID, for example:#greentext {
color: green; }
l An inline style rule (local formatting) added to the HTML tag of a particular table cell, for
example:<td style="color: green;">...</td>
Each of these rules is more specific than the previous rules. All of these rules are more specific
than the rule that applies to the table as a whole.
Determining the order in which style sheets are read
For each section, the style sheets are applied in a certain order. The styles in each following
style sheet add up to the styles found in previously read style sheets. When style sheets have a
conflicting rule for the same element, class or ID, the last style sheet wins’ and overrides the
rule found in the previous style sheet.
The order in which style sheets are applied, can be changed per section in any context, and for
the Web context as a whole:
Page 497