3

I would like to select the a element that is a parent .........................

i have aClass and cClass.. aClass is parent and cClass is child Class..

 <div class="a">
  <div class="c">mgmg</div>
</div>

<div class="a">
  <div class="c">mgmg</div>
</div>

<div class="a">

</div>

<div class="a">
   <div class="c">mgmg</div>
</div>

//how use parent select csscode

.a < .c{

       border:1px solid red;
       color:red;
       background-color:green;
 }
aungnyeinmin
  • 237
  • 3
  • 12
  • there aren't any [Check This](http://stackoverflow.com/q/1014861/3639582) – Shaunak D Jun 27 '14 at 10:59
  • 3
    This is the second time I've seen someone on here use `<` claiming it's "the CSS parent selector" and asking why it's not working. Where are they getting this from? – BoltClock Jun 27 '14 at 11:00
  • @BoltClock it was suggested as a way to make a parent selector but not accepted – Dreamwalker Jun 27 '14 at 11:01
  • @Dreamwalker: *Exactly.* I'm baffled as to how people take that to mean that it is valid and *should* work. – BoltClock Jun 27 '14 at 11:05

1 Answers1

3

This is not possible in CSS alone. CSS can only traverse down the DOM.

An alternative is to use javascript to find all your .c elements and find their parent .a, if it exists.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339