views:

24

answers:

1

Hello!

For the below code:

<div id="main">
   <div class="one"></div>
   <div class="two"></div>
   <div class="three"></div>
</div>

I want to select all of the 3 divs inside by class name and parent like this:

div#main div.one div.two div.three{/*apply common properties for all 3*/}

^ Doesn't work.

This is an abstract example so I need a solution similar to the one above, things like:

div#main>div{/*apply common properties for all 3*/}

Would not work in the real-case scenario.

Thank you.

+3  A: 

Hello, I don't think you have any other choice than this syntax :

div#main div.one,
div#main div.two,
div#main div.three
{/*apply common properties for all 3*/}
greg0ire
Thanks, I know about that, but I was hoping for a shorthand if any. In the real-case example, I have more than 3 divs.
Francisc
+1 for interesting question, I have already thought about that, but found nothing :(
greg0ire
Hm, ok. Thank you for your answer. My problem was that besides having a few more divs, the "path" to them is like: div#main div.something div.anotherThing div.one/two/three. Oh well, I'll just do it the long way. Thanks again.
Francisc