:first-child

W3C CSS Snapshot 2026

Match an element when it is its parent’s first element child.

On this page

Syntax and values

Value or syntaxWhat it does
li:first-childMatches an li when no element sibling comes before 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>:first-child</title>
  <style>
li:first-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 first list item changes color.

Official references