How would I select all but the last child using CSS3 selectors?
For example, to get only the last child would be div:nth-last-child(1)
.
There is a:not selector in css3. Use :not() with :last-child inside to select all children except last one.
This selector is used to select every element which is not the first-child of its parent element. It is represented as an argument in the form of :not(first-child) element.
You can use the negation pseudo-class :not()
against the :last-child
pseudo-class. Being introduced CSS Selectors Level 3, it doesn't work in IE8 or below:
:not(:last-child) { /* styles */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With