0

I have the following HTML example code:

<div>
    <span class="foo">
</div>

<div>
    <span class="moo">
</div>

I want to add some CSS styles to the div that contains a child with moo class. Can I add a style to an element, when containing a specific child, with CSS only ?

web-tiki
  • 99,765
  • 32
  • 217
  • 249
mashiah
  • 109
  • 2
  • 11

2 Answers2

1

No, you can't select parent in pure css. you will have to add a class to your parent div

Crock
  • 121
  • 6
0

Use this

 $(".moo").parent().css("...","...")

There is no pure CSS solution. U have to resort to jquery or jscript

user786
  • 3,902
  • 4
  • 40
  • 72