Forum Moderators: not2easy

Message Too Old, No Replies

accessing parent tag attributes

How do acess a parent tag with specific children

         

tforcram

6:13 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



This is actually CSS with XML, but I figure the principle should be the same. Here's the problem.
I'm trying to set some tags to display:none depending on whether or not they have a specific descendent tag. This is a shortened version of what the XML would look like:
<section id="1">
<info>
blah
</info>
</section>

<section id="2">
no info tag here
</section>

The question is, is there a way to set the second tag to display:none, and still have the first one display:[whatever]. I thought I had seem somewhere that you could access parent tags throgh children or something, but I can't find anything on it. Anyone have any ideas, or is this just an impossible task?

drbrain

7:46 pm on Sep 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't be done, CSS does not allow you to arbitrarily walk the tree, only a straight-line path.

CSS2 allows you to select based on an element's parents* (' ', '>') and to a limited extent siblings of its parents ('+'). CSS3 allows you slightly more leeway in selecting siblings of an element's parents ('~').

* Its easier to see how a selector matches if you reverse it.