This page is Ready to Use

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.

: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