- External styles in the DOM (
<link rel="stylesheet" href="style.css">
). - Internal styles in the DOM (
<style>
). - Inline styles in HTML elements (
<div style="color: red;">
). - External styles in CSS area (
@import
).
- User styles with
!important
. - Author styles with
!important
. - Author styles (see CSS declarations).
- User styles (users own stylesheets, addons, Developer Tools).
- User-agent styles (browser defaults).
- 1000 points for the inline style attribute (
<div style="color: red;">
). - 100 points for every ID (
#identifier
). - 10 points for every class (
.class
), attributes ([attributes]
) and pseudo-classes (:focus
). - 1 point for every element name (
div
) and pseudo-elements (:before
).
The latest rule defined in the DOM is the one that counts.
p { color: red; }
p { color: green; }
In the example above, every paragraphs would appear in green text.
a:link
a:visited
a:hover
a:active
- IE6 doesn't support
!important
.