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
Share this Page URL
Help

8. Working with Style Sheets > The Importance of Location

The Importance of Location

It’s not unusual for more than one style rule to apply to the same element, particularly on larger sites that require more effort to manage the CSS. As mentioned in “The Cascade: When Rules Collide” in Chapter 7, a style’s location can break a tie in the contest between inheritance and specificity. The basic rule is that, with all else equal, the later the style appears, the more precedence or importance it has (Image through Image).

Image In this example, the style element comes last. Therefore, its rules will have precedence over the rules in the base.css style sheet (as long as the conflicting rules have the same inheritance and specificity factors).


...
<head>
     <title>El Palau de la Música</title>
     <link rel="stylesheet" href="base.css" />
     <style>
     img {
        border-style: dashed;
     }
     </style>
</head>
...


  

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