How to style parent when parent contains specific child?

voineergo

New Member
I have some html that looks like this:\[code\]<div id="parent"> <div id="child"></div></div>\[/code\]I want to apply a default background color to \[code\]#parent\[/code\] except for when it contains a \[code\]#child\[/code\].So the CSS should end up looking something like this:\[code\]#parent { background: red}#parent:contains(#child) { background: none}\[/code\]However, I can't get the \[code\]:contains\[/code\] pseudo selector to work that way. Is there a way to achieve this?
 
Back
Top