I'm inspecting an h2
element on a web page using Google Chrome's element inspector and some of the CSS rules--which appear to be applied--are grayed out. It seems that a strike-through indicates that a rule was overridden, but what does it mean when a style is grayed out?
views:
54answers:
1
+1
A:
It means the rule has been replaced with another rule with higher priority. For example stylesheets with:
h2 {
color: red;
}
h2 {
color: blue;
}
The inspector will show the rule color:red;
grayed out and color:blue;
normally.
Read up on CSS inheritance to learn which rules are inherited/have higher priority.
EDIT:
Mixup: the grayed out rules are the unset rules, which use a special default stylesheet that is applied to all elements(the rules that make the element renderable, because all styles have to have a value).
digitalFresh
2010-07-16 14:01:01
`s/priority/specificity/` :)
J-P
2010-07-16 14:01:57
s/replaced/overridden by/ :)
annakata
2010-07-16 14:03:34
I just tested this and I think that is incorrect. In the case where a rule is overridden, there'll be a strike-through (as my question indicates). See: http://yfrog.com/f/j3fooep/
Rob Sobers
2010-07-16 14:05:45
@Rob: had a mixup since devtools wasnt starting. I got it running, and edited my answer with my *tested* answer.
digitalFresh
2010-07-16 14:40:01
@digitalFresh: I'm not entirely sure that's correct either; the faded rules are ones I've set in my own styles sheet (e.g., `font-size: 20px;`)
Rob Sobers
2010-07-16 20:17:09