1

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?

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

6 Comments

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!
Try and avoid doing this as it performs extremely poorly.
Yes, I can see that it might be problematic, but for special cases it could be useful.
@cletus, what do u mean by 'extremely poorly'? the parent>child ? poor is slow/ not good visual results?:D?
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.
|
6

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.