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
  • 87,261
  • 27
  • 200
  • 230
mashiah
  • 99
  • 2
  • 9

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
  • 2,727
  • 3
  • 24
  • 45