Applying Styling to All But the First Element of a Certain Type | Task

Ole Ersoy
Feb - 17  -  1 min

Scenario

We have the following div elements:

  <div>Box 1</div>
  <div>Box 2</div>
  <div>Box 3</div>

We want to assign a left margin of 2rem to all but the first div element.

Approach

div:not(:first-of-type) {
  margin-left: 2rem;
}

Demo