Placing a Bottom Border on All Elements Except for the Last Child | Task

Ole Ersoy
Dec - 31  -  1 min

Scenario

We are creating a navigation container and we wish to place a bottom border all all but the last child element within the container.

Approach

We will contain all the navigation div elements within a main element. Then select all but the last div and apply the bottom border.

main div:not(:last-child) {
  border-bottom: 2px solid black;
}

Demo