Hi! I read that IE 8 accepts child selectors. But it does not seem to work for my IE8 (Spanish version if this even matters).

#div > p{background-color: blue;}
========================
<div id="div">
<p>Shoud work here!</p>
        <div>
                <p>and not here</p>
        </div>
</div>

It works for firefox and not for internet explorer. What could be happening?

Recommended Answers

All 2 Replies

Hi! I read that IE 8 accepts child selectors. But it does not seem to work for my IE8 (Spanish version if this even matters).

#div > p{background-color: blue;}
========================
<div id="div">
<p>Shoud work here!</p>
        <div>
                <p>and not here</p>
        </div>
</div>

It works for firefox and not for internet explorer. What could be happening?

What DTD are you using? Might require STRICT mode.
But if you are working in a strict document than it will mean it doesn't support direct child selector syntax.

But this is a highly effective workaround - try this.

<style type="text/css">
            #div p{background-color: blue;}
            #div div p{background-color: transparent;}
	</style>

IE sometimes gets confused when you name a class or an id using a tag name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.