2019-11-23
Select all except last
In common cases, you may need to put a margin-bottom
to all elements except the last one.
It's easy! Just use :not(:last-child)
.
List example
li:not(:last-child) {
margin-bottom: 1rem;
}
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
Sources:
Comments