Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Woo hoo! It’s time for an example. Say you want to know the color property for this <h1> element:
<h1 class="blueberry">Blueberry Bliss Elixir</h1>
Let’s take this through all the cascade steps:
Remember, you’re the browser, because you’re trying to figure out how to display this <h1> element.
Step one:
Gather all your style sheets together.
Step two:
Find all the declarations that match.
Step three:
Now take all your matches, and sort them by author, reader, browser.
Step four:
Now sort the declarations by how specific they are. To do that we need to first calculate each specificity score, and then reorder the rules.
Finally, sort any conflicting rules in the order that they appear in their individual style sheets.