Basics:
As long as you use the same selectors, this is true:
Inline styles has priority 1
Styles defined in head has priority 2
Styles in linked stylesheet has priority 3
But there's also further priority rules
If you only use linked stylesheet or define styles in head, this is true:
Priority 1: ID's (because there can be only one)
Priority 2: .classes (because there must be a .class added)
Priority 3: tags (lowest priority because no .class or ID's are attached)
The closer the ID is to body, the higher the priority.
<div id="first-id">
<div id="second-id">
<div class="someclass">
</div>
</div>
</div>
#first-id .someclass {}
beats
.someclass {}
as well as
#second-id .someclass {}
BUT
You can make .someclass beat the ID's by using
.someclass { color:#f00 !important;}
But I'm not sure about the browser support on !important;