CSS Reference ยท Scrolling, Interaction and UI
The pointer-events property
Reference for the CSS pointer-events property: let clicks and hovers pass through an element, re-enable them on children, and avoid the keyboard trap.
The pointer-events property decides whether an element can be the target of mouse, touch and pen input. With the default auto, the element reacts to clicks, taps and hovering. With none, the pointer behaves as if the element were not there, so the event goes to whatever sits underneath.
The most common use is a decorative layer, such as a gradient overlay or a custom focus glow, that covers an interactive element but must not steal its clicks.
.overlay { pointer-events: none; }
Try it
Both buttons look the same, but only the one under the pointer-events: none overlay receives your clicks.
Syntax
pointer-events: auto | none /* SVG content only */ pointer-events: bounding-box | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all
- Initial value:
auto - Applies to: all elements
- Inherited: yes
- Animatable: no (it switches discretely)
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
Normal behavior: the element can be the target of pointer events. For SVG it behaves like visiblePainted. |
none |
The element is never the target. Events go to the element behind it, and it does not match :hover or :active from the pointer. |
visiblePainted, visibleFill, visibleStroke, visible, painted, fill, stroke, all |
SVG-specific values that choose which parts of a shape (fill, stroke, visible or hidden parts) react. They have no effect on ordinary HTML boxes. |
Usage notes
- Children can opt back in. The property inherits, so
pointer-events: noneon a parent switches off the whole subtree, but a child withpointer-events: autobecomes clickable again. This is handy for a click-through layer with a few interactive controls on it. - It is not a way to disable things.
pointer-events: nonestops mouse and touch input only. A button or link can still be reached with the Tab key and activated with Enter or Space. To really disable a control, use thedisabledattribute on form controls, or theinertattribute to take a whole region out of reach for every kind of input. - Screen readers are unaffected. The element stays in the accessibility tree, so assistive technology still sees and announces it.
- Hover and cursor. An element with
nonedoes not show its owncursor, and it does not trigger its:hoverstyles. The element underneath gets both instead. - Text selection. Text inside an element with
nonecan usually not be selected by dragging with the mouse. Useuser-selectto control selection explicitly. - Common use cases. Decorative overlays, tooltips that should not block the page, drag previews, and dimmed elements while a request is running. For the last case, also set
aria-disabledorinertso keyboard users are treated the same way.
Browser support
Supported in all current browsers for HTML and SVG; the SVG-only values and bounding-box matter only in SVG.
Related
user-selectโ controls text selectioncursorโ sets the mouse cursorinteractivityโ a newer way to make a subtree inerttouch-actionโ controls touch gestures- Lessons: User Interface, Accessibility