CSS3 :last-childSelectors
Complete CSS Selector Reference Manual
Example
Set the background color of the last p element in the parent element:
p:last-child
{
background:#ff0000;
}
Try it Yourself »
Definition and Usage
The :last-child selector is used to match the last child element of the parent element.
Tip:p:last-child is equivalent to p:nth-last-child(1).
Browser Support
| Selectors | |||||
|---|---|---|---|---|---|
| :last-child | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
More Examples
Example
Select the last li element in the parent element ul and set the background color:
li:last-child {
background-color: #ff0000;
}
Try it Yourself »
other extensions