HTML and CSS Reference
So, to review, as the page authors, we
can use multiple stylesheets with our HTML.
And the user might also supply his own styles,
and then the browser has its default styles,
too. And on top of all that, we might have
multiple selectors that apply to the same
element. How do we figure out which styles
an element gets?
That's actually another way of asking what
cascade does. The cascade is the way the
browser decides, given a bunch of styles
in a bunch of stylesheets, which style is
going to be used. To answer that question,
we need to bring everything together — all
the various stylesheets hanging around,
the rules, and the individual property
declarations in those rules.
In the next two pages, we're going to step
through the nitty-gritty details of how all
this works. The details involve a lot of
sorting and various details of determining
which rules are the most specific with
respect to an element. But here's the payoff:
after going through the next two pages,
you'll be able to get to the bottom of any
styles that don't seem to be applied in the
way you expect, and further, you're going
to understand more about the cascade than
99% of web page developers out there
(we're not kidding).