CSS and the precedence of cascading styles
Go to CSS: Basics
The precedence of cascading styles in CSS listed in order of the highest priority:
1. Inline styles: style attribute and span element
2. Style element: as a block contained in the head of the page
3. External style sheets
4. User agent's default style sheet
The general rule with cascading styles is that the most specific style wins.
Thus, if you have one style about <body> and another about <h1>, the <h1> is more specific, so will follow the second style in the case of a conflict.
A 'class' style takes precedence over a redefined XHTML element such as <h1>, and an 'id' takes precedence over a 'class'.
If two conflicting styles are equally specific, the style declared later in the style sheet takes precedence.
These rules in action are described with code examples in CSS: Basics and CSS: Basics plus.
Copyright © 2006-2012 justfigures.co.uk

