This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

:last-child

Summary

The :last-child pseudo-class represents the last child element of its parent.

Examples

/*We add some red color to the second list item*/

li:last-child {
color: red;
}

View live example

<ul>
    <li>I'm not red!</li>
    <li>I'm red!</li>
</ul>

Notes

Remarks

The :last-child pseudo-class is a structural pseudo-class. Structural pseudo-classes enable selection based on extra information in the document tree that can’t be selected using simple selectors or combinators.

Syntax

selector

last-child
### Parameters
selector
A CSS simple selector.

Standards information

Related specifications

CSS Selectors Level 3
W3C Recommendation

See also

Related pages

Attributions