The CSS Cascade and why you should care
It comes down to CSS Specificity and CSS Cascading. Tread carefully and know what you're doing and CSS Specificity can be your friend.
// bring CSS into the Page
<style type="text/css">@import url("importedStyles.css");</style>
/// Link to CSS Style Sheet
<link rel="stylesheet" type="text/css" href="linkedStyles.css" />
Since @import brings the style into that page, those rules will override External or "linked" stylesheets. In-Line CSS trumps either because of a higher CSS specificity:
<span style="color: red;">I am DEFINITELY RED</span>
However, this only works when the rules are the same specificity
Take the following:
<div class="error">I am an error message</div>
If I have a rule in the importedStyles.css of so:
.error { color: blue; } /* specificity = 10 */
And a rule in "externalStyles.css" like so:
div.error { color: red; } /* specificity = 11 */
It will take the externalStyles version
Note: CSS specificity of inline style is 1000, so it trumps all things, except the !important tag which is 10000. Another CSS Specificity Article
CSS Specificity Reference
So, some examples:
body .selected { color: red; } /* 11 */
ul li { color: red; } /* 2 */
ul li.selected { color: blue; } /* 12 */
#content ul li.selected a { color: red; } /* 113 */
/* Careful, can't override this, ever */
a { color: blue; !important } /* 10,000 - Override everything */
So... the Cascade applies to element of the same Specificity only. Cascades are applied AFTER specificity rules are applied.