views:

54

answers:

1

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?

+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
`s/priority/specificity/` :)
J-P
s/replaced/overridden by/ :)
annakata
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
@Rob: had a mixup since devtools wasnt starting. I got it running, and edited my answer with my *tested* answer.
digitalFresh
@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