0

Now I have html:

<div class="box">
   <span class="title">first</span>
   <span>second</span>
   <span>third</span>
   <span>fourth</span>
</div>

And Sass:

.box {
    background-color: gray;
    span {
       margin: 10px;
       &.title {
          color: red;
       }
    }
}

I would like to remove class .title and replace &.title with a any selector.

Is it possible without class in first element? I would like to in HTML simply:

<div class="box">
   <span>first</span>
   <span>second</span>
   <span>third</span>
   <span>fourth</span>
</div>

And first span have to has red color.

nihidu
  • 3
  • 1
  • 2

1 Answers1

2

Yeah that's possible event without sass have a loook at:

pseudo-selectors

:first-of-type or :first-child

Synoon
  • 2,297
  • 4
  • 22
  • 37