mars-o
mars-o

Reputation: 1715

parent>child CSS selector

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?

Upvotes: 3

Views: 2522

Answers (2)

John Feminella
John Feminella

Reputation: 311695

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.

Upvotes: 11

Joel
Joel

Reputation: 19368

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.

Upvotes: 6

Related Questions