← Back to pseudo-classes
CSS Pseudo-class / Element
:first-child
StructuralSelects an element that is the first child of its parent.
Syntax
selector:first-child { }Example
li:first-child { font-weight: bold; }Common use cases
- Removing top margin on first element
- Styling the first item in a list differently
- Adding borders between items without affecting the first
Practical developer insight
If the first child is not the element type you're targeting, the selector won't match — use :first-of-type in that case.