← Cheat Sheets

CSS Pseudo-Classes and Pseudo-Elements

State, structure and generated content.

# CSS Pseudo-Classes and Pseudo-Elements

State, structure and generated content.

| Selector | Meaning |
|---|---|
| `:hover` `:focus` `:active` | Interaction states |
| `:focus-visible` | Keyboard focus |
| `:disabled` `:checked` `:required` | Form states |
| `:first-child` `:last-child` | Position |
| `:nth-child(2n+1)` | Odd children |
| `:nth-of-type(3)` | Third of its type |
| `:empty` | No children |
| `::before` `::after` | Generated content (needs `content`) |
| `::first-line` `::first-letter` | Text parts |
| `::placeholder` | Input placeholder |
| `::selection` | Selected text |