i frequently use this CSS selector parent>child. my design looks good in Mozilla and Opera. But in IE, it sucks. i know > is not recognizable in IE, but what is the alternate to that in IE? thanks.
+4
A:
There is no alternate for the direct child selector in IE6 (it should work in IE7 though).
Instead you need to use the descendant selector (a space) and design your classes to compensate.
Joel Potter
2009-03-11 01:08:08
+6
A:
One alternative is to use the universal selector to make a more specific rule which will take effect if the nodes aren't direct children:
div p {color: red;} // Takes effect if there's a <p> child at some level
div * p {color: black;} // .. but this'll be true if it's not a direct child
However, you need to watch out for specificity conflicts. div * p
will be more specific than another rule that works on paragraphs in general, for example.
John Feminella
2009-03-11 01:10:22
+1: I've never seen that before (and I've done a lot of css). Good idea.
Joel Potter
2009-03-11 01:17:10
Thanks for the upvote. But I'd definitely be careful about using this -- it can lead to serious pain if it's done too liberally. Specificity conflicts are evil stuff!
John Feminella
2009-03-11 01:18:20
Try and avoid doing this as it performs extremely poorly.
cletus
2009-03-11 01:33:06
Yes, I can see that it might be problematic, but for special cases it could be useful.
Joel Potter
2009-03-11 01:52:40
@cletus, what do u mean by 'extremely poorly'? the parent>child ? poor is slow/ not good visual results?:D?
bgreen1989
2009-03-11 03:55:01
I think he means that the use of the universal selector will cause this CSS rule to apply to a lot of nodes, which is inefficient.
John Feminella
2009-03-11 15:09:18