Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
styles, including !important author styles. Both author and reader styles override the user agent's default styles. 3. Sort by specificity all declarations applying to a given el- ement. Those elements with a higher specificity have more weight than those with lower specificity. 4. Sort by order all declarations applying to a given element. The later a declaration appears in a style sheet or a docu- ment, the more weight it is given. Declarations that appear in an imported style sheet are considered to come before all declarations within the style sheet that imports them, and have a lower weight than those in the importing style sheet. Any presentational hints that come from non-CSS sources (e.g., the preference dialog within a browser) are given the same weight as the user agent's default styles (see step 2 above). Element Classification Broadly speaking, CSS groups elements into two types: non- replaced and replaced. Although the types may seem rather ab- stract, there actually are some profound differences in how the two types of elements are presented. These differences are explored in detail in Chapter 7 of CSS: The Definitive Guide, third edition (O'Reilly). Nonreplaced Elements The majority of HTML and XHTML elements are nonreplaced elements, which means their content is presented by the user agent inside a box generated by the element itself. For example, <span>hi there</span> is a nonreplaced element, and the text hi there will be displayed by the user agent. Paragraphs, head- ings, table cells, lists, and almost everything else in HTML and XHTML are nonreplaced elements. Element Classification | 9