views:

40

answers:

2

I want to match a with id "breadCrumb" only if it has a child span id "userName".

Match:

<div id="breadCrumb" class="nav">
    <span id="userName">esac</span>
</div>

But not match:

<div id="breadCrumb" class="nav">
    <span id="navtrail">...</span>
</div>

I want to set #breadCrumb { display: none; }, but I don't want to hide it in the second case.

+1  A: 

It's not possible by design. Duplicate question.

porneL
A: 

Firstly, these two elements aren't on the same page are they? If so it's invalid HTML as you can't (shouldn't) duplicate IDs.

You can't do this with straight CSS. My advice would be to restate the problem:

<div id="breadCrumb" class="nav userName">
    <span>esac</span>
</div>

or

<div id="breadCrumb" class="nav navtrail">
    <span>...</span>
</div>

then you can do things like:

#breadCrumb.navTrail { display: none; }

or

div.nav.navTrail { display: none; }

Applying multiple class selectors (previous example) isn't supported in IE6.

cletus
Nope, they are not on the same page. On this site, I am allowed to customize CSS, but it applies to every page on the site.
esac