views:

73

answers:

2

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)

+3  A: 

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 */ }
Nick Craver
A: 

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+).

Nicholas Wilson