tags:

views:

324

answers:

2

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
+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
+1: I've never seen that before (and I've done a lot of css). Good idea.
Joel Potter
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
Try and avoid doing this as it performs extremely poorly.
cletus
Yes, I can see that it might be problematic, but for special cases it could be useful.
Joel Potter
@cletus, what do u mean by 'extremely poorly'? the parent>child ? poor is slow/ not good visual results?:D?
bgreen1989
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