Hover and Focus States
Pseudo-classes let you style elements based on their state, like when hovered or focused.
The :hover Pseudo-class
Style elements when the mouse is over them:
Loading CSS Playground...
The :focus Pseudo-class
Style elements when they have keyboard focus:
Loading CSS Playground...
The :active Pseudo-class
Style elements while being clicked:
Loading CSS Playground...
Link States
Links have special pseudo-classes for their states:
Loading CSS Playground...
Card Hover Effects
Loading CSS Playground...
Focus-Visible
:focus-visible only shows focus styles for keyboard navigation:
Loading CSS Playground...
Exercise: Style Button States
Create hover and focus styles for a button:
Loading CSS Exercise...
Up next · Lesson 11 of 27
Structural Pseudo-Classes
2 min read
10 of 27 lessons done

