Interaction

pointer-events

pointer-events sets whether an element receives mouse and touch input. With none, input passes through the element to whatever is behind it.

Syntax

auto | none

Preview

Clicks: 0Overlay on top
Presets
Drag the bottom-right corner to resize

Code

.box > :nth-child(2) {
  pointer-events: none;
}

Controls

pointer-eventsnone
pointer-events
Clicks: 0Overlay on top

About

Values

  • auto (initial): receives clicks and hovers as usual.
  • none: the element is treated as if it were not there, so the element behind it gets clicked. :hover and the cursor shape come from the element behind as well.

The preview sets it on the yellow overlay sitting on the lower right of the button. With none, hovering over the overlay still changes the button color, and clicking it adds to the count.

When to use it

Use it on elements layered on top only for looks, such as a gradient over the edge of a list or decorative text over an image, so they don’t get in the way of what’s underneath.

Watch out

  • It is inherited. Children of a none element don’t receive input either, but setting pointer-events: auto on a child turns it back on for that child.
  • It doesn’t stop the keyboard. A button or link with none can still be reached with Tab and pressed with Enter. To really disable something, use the disabled attribute on form controls, or the inert attribute for a whole section.
  • There are other keywords such as visiblePainted, fill and stroke, but they are meant for SVG shapes; their effect on HTML elements is not defined.

Comments