The Importance of Location

With so many ways to apply styles, it’s not unusual for more than one style rule to apply to the same element. As we discussed in Chapter 7, Style Sheet Building Blocks, and specifically on pages 122123, a style’s location can break a tie in the contest between inheritance and specificity. The basic rule is, with all else equal, the later the style appears, the more precedence or importance it has.

Figure 8.21. 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).

So, locally applied styles (see page 134) have the most precedence and will override any ...

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.