Skip to content

CSS Selectors

Hover

About

The :hover pseudo-class matches elements that are currently being hovered over by the mouse cursor. This also matches parent elements of the hovered element.

Hovered element

The selector matches if you hover over the element.

  • Hover over the button to make the selector match

Hovered element (parent)

If you hover over an element, the selector also matches its parent elements. Interactive elements like buttons cannot be nested but the selector works on other elements like a div.

  • Hover over the child element to make the selector match the child and the parent
Hover me (parent)
Hover me (child)