Easy Tutorial
❮ Pr Text Text Indent Css3 Pr Border Image Repeat ❯

CSS3 :last-child Selector

Complete CSS Selectors Reference

Example

Specify the background color of the last p element in a parent element:


Definition and Usage

The :last-child selector is used to match the last child element of a parent.

Tip: p:last-child is equivalent to p:nth-last-child(1).


Browser Support

Selector
:last-child 4.0 9.0 3.5 3.2 9.6

More Examples

Example

Specify the last li element in a parent ul and set its background color:


Complete CSS Selectors Reference

❮ Pr Text Text Indent Css3 Pr Border Image Repeat ❯