It seems elementary, but here is problem.
Stylesheet like so:
#Content h1, #Content h2, #Content h3, #Content h4, #Content h5, #Content h6 { color: #405679; } h3#issueHeader { color: blue; }
HTML like so:
<div id="Content"> <h3 id="issueHeader">In This Issue:</h3> </div>
Instead of my issueHeader selector overriding the Content selector like I would expect, Firebug and my eyeballs show me that the color is inherited from the div, and the issueHeader selector is overridden. Hunh?
If you can see your new CSS in the Styles pane, but your new CSS is crossed out, it means that there's some other CSS that is overriding your new CSS. In CSS terminology this concept is called Specificity. Chrome DevTools can help you find the old CSS that is causing your new CSS to not be applied.
Using HTML Code in this way creates an internal stylesheet (on the page) that overrides any same-specificity CSS defined in the external stylesheets of your themes and modules. This is handy when you want to test changes of your existing module and frontend theme styles, without having to recompile .
Inline styles added to an element (e.g., style="font-weight: bold;" ) always overwrite any normal styles in author stylesheets, and therefore, can be thought of as having the highest specificity.
You can throw the !important
attribute on h3#issueHeader
to force the browser to use that style
h3#issueHeader { color: blue !important; }
However, it is only partially supported in IE6
CSS
gives more weight to styles with more specific selectors. So if you want #Content h3
not to override h3#issueHeader
, give it another selector: e.g. #Content h3#issueHeader
If your h1...hx elements are meant to be generally #405679, set them to that without the #Content selector. Then override them with a more specific selector when you need to.
However, because the way weight is calculated, we need to use closest element/class in our selector to get enough-weight, for example:
z
" element.y z
" selector (without quotes).a b c
" all the way to "u v w
" (without x
).y z
".x y z
" selector will have enough weight (as x-tagged-element is parent of y-tagged-element).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With