|
||||
|
Which Styles Are "More Important"
CSS styles can exist at so many levels: inline, internal, external, and have so many forms: tag rewrites, id styles, class styles. Which ones take "precedence" over the others? Or, if two styles conflict - say two different text-sizes - which one rules? This is called specificity in CSS, and there is actually a mathematical hierarchy that determines specificity. With the idea of specificity comes the idea that the more specific you are, the more important the code is. It's similar to the idea that the closer an HTML tag is, the more likely it is to affect the page element. What size will the text be if you have the following properties or rules?
Because styles and the places they are used can come in quite a variety of combinations, specificity has to take many factors into consideration. Items 1 - 3 only have one selector each: body, #ContentArea, .BodyText. However, selectors can also be combined:
Selectors can be much more complicated than we will get in the Web Development with CSS class. Numeric Pattern for Specificity
CSS: The Definitive Guide |
||||
|
Nora McDougall | Missoula, Montana
59801 | 406.253.4045 |
Contact Nora
© 2010, Nora McDougall-Collins |
||||