Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Putting it all together

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:

Note

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.

image with no caption
image with no caption
image with no caption

Step two:

Find all the declarations that match.

image with no caption

Step three:

Now take all your matches, and sort them by author, reader, browser.

image with no caption

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.

image with no caption

Step five:

Finally, sort any conflicting rules in the order that they appear in their individual style sheets.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial