CSS Parent/Ancestor Selector

Steve picture Steve · Aug 9, 2009 · Viewed 46.3k times · Source

Possible Duplicate:
Is there a CSS parent selector?

I know this is a shot in the dark, but is there a way, using css only, CSS2, no jquery, no javascript, to select and style an element's ancestor? I've gone through the selectors but am posting this in case I missed something or there is a clever workaround.

For example, say I have a table with classname "test" nested inside a div. Is there some sort of:

<div>
    <table class="test">
    </table>
</div>
div (with child) .test
{
     /*styling, for div, not .test ...*/
}

Answer

ChssPly76 picture ChssPly76 · Aug 9, 2009

There is no such thing as parent selector in CSS2 or CSS3. And there may never be, actually, because the whole "Cascading" part of CSS is not going to be pretty to deal with once you start doing parent selectors.

That's what jQuery is for :-)