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)
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)
You can use the negation pseudo-class :not()
against the :last-child
pseudo-class, but being CSS3, it won't work in IE:
:not(:last-child) { /* styles */ }
When IE9 comes, it will be easier. A lot of the time though, you can switch the problem to one requiring :first-child and style the opposite side of the element (IE7+).