2

Is there a way to apply styles to all the elements of a class directly without having to write like this:

.element-wrapper .coin-box{
  margin: 10px;
  float: left;
}

.element-wrapper .platform{
 margin: 10px;
 float: left;
}

.element-wrapper .goomba{
  margin: 10px;
  float: left;
}
Pratish Shrestha
  • 1,712
  • 4
  • 17
  • 26

3 Answers3

8

you can use * selector, for example:

.element-wrapper *{
      margin: 10px;
      float: left;
    }
3

Descendent selectors are very similar to child selectors, except that child selectors only select immediate descendents; descendent selectors select matching elements anywhere in the element hierarchy, not just direct descendents. Let's look at what this means more carefully.

CSS:

.element-wrapper >  *
 {
    margin: 10px;
    float: left;
 }

It will work more consistently :-

rajesh
  • 1,475
  • 10
  • 23
0

you could do it like this

 .element-wrapper .coin-box, .element-wrapper .platform, .element-wrapper .goomba {
  margin: 10px;
  float: left;
}