pocesar
pocesar

Reputation: 7050

CSS :last-child:not(:only-child) not working as expected

Currently, I have this selector:

.form .mid td p:last-child:not(:only-child) {
    margin-bottom: 0; 
}

It's not working as intended. I want to remove the margin ONLY if there are more than one P inside the TD

Upvotes: 13

Views: 17698

Answers (1)

BoltClock
BoltClock

Reputation: 723739

If your td contains more than just p elements (I can't tell because you haven't shown your markup), you probably want to use :last-of-type and :only-of-type instead:

.form .mid td p:last-of-type:not(:only-of-type) {
    margin-bottom: 0; 
}

Upvotes: 21

Related Questions