:last-child
W3C CSS Snapshot 2026
Match an element when it is its parent’s last element child.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
li:last-child | Matches an li when no element sibling comes after it. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>:last-child</title>
<style>
li:last-child { color: teal; }
</style>
</head>
<body>
<ul>
<li>Check in</li>
<li>Pick up materials</li>
<li>Find a seat</li>
<li>Start the activity</li>
</ul>
</body>
</html>
What to expect Only the last list item changes color.