CSS
CSS Pseudo-ClassesCSS Pseudo-Classes
CSS pseudo-classes style elements based on their current state.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
CSS pseudo-classes change an element's appearance when a user interacts with it. A common example is changing a button's color when the mouse hovers over it. They attach to regular selectors using a single colon.
Syntax
Syntax
Example
Example
Key Points
- Pseudo-classes reflect user interactions.
- The `:hover` pseudo-class triggers on mouse over.
- The `:focus` pseudo-class triggers when clicking an input field.
- The `:nth-child()` pseudo-class targets specific items in a list.