CSS pointer-events Property
The CSS pointer-events property controls whether an element can become the target of pointer interactions, such as mouse clicks, touch input, and pointer movement.
It is commonly used to allow clicks to pass through decorative overlays, prevent pointer interactions with specific elements, and control which parts of an SVG graphic can receive pointer events. It does not disable keyboard interaction or remove an element from the document.
pointer-events Syntax
The pointer-events property accepts a single keyword that determines how an element participates in pointer hit testing.
Basic Syntax
selector {
pointer-events: none;
}
This prevents the element itself from becoming the target of pointer events.
Common Values
.element {
pointer-events: auto;
}
.element {
pointer-events: none;
}
For ordinary HTML elements, auto and none are the primary values used in production layouts.
SVG Values
.svg-shape {
pointer-events: visiblePainted;
}
.svg-shape {
pointer-events: visibleFill;
}
.svg-shape {
pointer-events: visibleStroke;
}
.svg-shape {
pointer-events: visible;
}
.svg-shape {
pointer-events: painted;
}
.svg-shape {
pointer-events: fill;
}
.svg-shape {
pointer-events: stroke;
}
.svg-shape {
pointer-events: bounding-box;
}
.svg-shape {
pointer-events: all;
}
These additional values are primarily defined for SVG graphics. Some have experimental application to HTML elements, so they should not be assumed to work consistently outside SVG.
CSS-Wide Keywords
.element {
pointer-events: initial;
}
.element {
pointer-events: inherit;
}
.element {
pointer-events: unset;
}
.element {
pointer-events: revert;
}
.element {
pointer-events: revert-layer;
}
CSS-wide keywords control how the property participates in inheritance and the CSS cascade.
Property Values
The available values determine whether an element can be selected during pointer hit testing. SVG provides additional control over which parts of a shape are interactive.
| Value | Description |
|---|---|
auto |
Uses normal pointer hit-testing behavior. This is the initial value. |
none |
Prevents the element itself from becoming a pointer event target. Descendants can remain targetable if they override the inherited value. |
visiblePainted |
For SVG, allows targeting painted fill or stroke regions when visibility is visible. |
visibleFill |
For SVG, allows targeting the fill region when visibility is visible, regardless of the fill paint value. |
visibleStroke |
For SVG, allows targeting the stroke region when visibility is visible, regardless of the stroke paint value. |
visible |
For SVG, allows targeting the fill or stroke region when visibility is visible. |
painted |
For SVG, allows targeting painted fill or stroke regions without requiring visible visibility. |
fill |
For SVG, allows targeting the fill region regardless of its paint or visibility settings. |
stroke |
For SVG, allows targeting the stroke region regardless of its paint or visibility settings. |
bounding-box |
For SVG, allows targeting the rectangular bounding box of the element. |
all |
For SVG, allows targeting fill and stroke regions regardless of paint or visibility settings. |
initial |
Resets the property to auto. |
inherit |
Uses the computed value from the parent element. |
unset |
Uses the inherited value because this property is inherited. |
revert |
Reverts the property according to CSS cascade origin rules. |
revert-layer |
Reverts the property according to CSS cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | All elements |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
Valid Values
.overlay {
pointer-events: none;
}
.button {
pointer-events: auto;
}
.svg-path {
pointer-events: visibleStroke;
}
.svg-shape {
pointer-events: bounding-box;
}
Invalid Values
.element {
pointer-events: disabled;
}
.element {
pointer-events: hidden;
}
.element {
pointer-events: click;
}
.element {
pointer-events: 50%;
}
.element {
pointer-events: auto none;
}
The property accepts one supported keyword, not arbitrary interaction states, percentages, or multiple independent values.
How It Works
Browsers use hit testing to determine which element is located beneath a pointer at a particular position.
Normal Hit Testing
.element {
pointer-events: auto;
}
The element participates in normal pointer hit testing and can become the target of applicable pointer events.
Skipping an Element
.element {
pointer-events: none;
}
The browser excludes the element itself as a pointer target. An eligible element underneath it may receive the interaction instead.
Visual Appearance Is Unchanged
Setting pointer-events: none does not hide an element, change its opacity, or remove it from the layout.
Inherited Behavior
The property is inherited. A child normally receives its parent's computed value unless it has its own declaration.
Pointer Events Are Not All Events
The property affects pointer targeting. It does not automatically prevent keyboard focus, programmatic activation, or every JavaScript event.
Event Propagation
Even when a parent uses pointer-events: none, its event listeners can run during event propagation if a targetable descendant receives an event.
auto vs. none
The two most frequently used values are auto and none.
pointer-events: auto
.button {
pointer-events: auto;
}
The element can become a pointer target according to normal browser hit-testing rules.
pointer-events: none
.button {
pointer-events: none;
}
The element itself is excluded from pointer targeting. Pointer interactions may reach an eligible element underneath it.
Comparison
| Behavior | auto |
none |
|---|---|---|
| Can be a pointer target | Yes, normally | No |
| Remains visible | Yes | Yes |
| Occupies layout space | Yes | Yes |
| Automatically prevents keyboard focus | No | No |
| Allows pointer targeting underneath | Not normally through the element | Yes, where an eligible target exists |
Restoring Normal Behavior
.element {
pointer-events: auto;
}
Use auto to restore normal pointer targeting after applying none.
Click-Through Overlays
A common use for pointer-events: none is a decorative overlay that should not interfere with elements underneath it.
Overlay Without Pointer Blocking
<div class="overlay-container">
<button type="button">Click Me</button>
<div class="decorative-overlay">Decoration</div>
</div>
.overlay-container {
position: relative;
}
.decorative-overlay {
position: absolute;
inset: 0;
pointer-events: none;
}
The overlay remains visible, but pointer interactions can reach the button beneath it.
Image Decorations
.decorative-image {
pointer-events: none;
}
This can prevent a decorative image from intercepting pointer interactions intended for underlying controls.
Overlay Labels
.overlay-label {
position: absolute;
top: 10px;
left: 10px;
pointer-events: none;
}
A noninteractive label can appear above a control without blocking pointer targeting.
Interactive Overlays
Do not apply pointer-events: none to an overlay that must intercept clicks, close a dialog, or otherwise receive pointer input.
Important Consideration
Click-through behavior depends on which eligible elements exist beneath the overlay. It does not guarantee that every pointer interaction reaches a particular control.
Parent and Child Interactions
Because pointer-events is inherited, parent and child declarations can produce useful combinations.
Disabling Pointer Targeting on a Parent
.parent {
pointer-events: none;
}
Descendants inherit none unless they explicitly override it.
Restoring Pointer Targeting on a Child
.parent {
pointer-events: none;
}
.child {
pointer-events: auto;
}
The parent itself remains excluded from pointer targeting, while the child can become a pointer target.
Practical Overlay Pattern
.overlay {
pointer-events: none;
}
.overlay .close-button {
pointer-events: auto;
}
This pattern can allow pointer interactions to pass through most of an overlay while keeping a specific control interactive.
Event Bubbling
If a child receives a pointer event, that event may still bubble through its parent. The parent's JavaScript event listener can run even when the parent uses pointer-events: none.
Pointer Enter and Leave Events
Pointer entry and exit events can still be observed on a parent when the pointer moves into or out of a targetable descendant.
Important Consideration
Removing an element from pointer hit testing is not the same as removing it from the event propagation path.
Pointer Events in SVG
SVG supports additional pointer-events values that control whether a shape can be targeted through its fill, stroke, painted regions, or bounding box.
Targeting the Stroke
.svg-line {
pointer-events: stroke;
}
The stroke region can receive pointer interactions even when the stroke paint is set to none.
Targeting the Fill
.svg-shape {
pointer-events: fill;
}
The shape's fill region can be targeted regardless of its fill paint setting.
Targeting Painted Regions
.svg-shape {
pointer-events: painted;
}
Only regions with applicable fill or stroke paint participate in targeting, regardless of the visibility property.
Targeting the Bounding Box
.svg-shape {
pointer-events: bounding-box;
}
The rectangular bounding box can become the pointer target area, even where the actual painted shape does not fill the rectangle.
Targeting All Fill and Stroke Regions
.svg-shape {
pointer-events: all;
}
Fill and stroke regions participate in targeting regardless of paint or visibility settings.
SVG Example
<svg width="180" height="120" viewBox="0 0 180 120" aria-label="Outlined circle">
<circle class="interactive-circle" cx="90" cy="60" r="40" fill="none" stroke="#2563eb" stroke-width="8" />
</svg>
.interactive-circle {
pointer-events: stroke;
cursor: pointer;
}
Only the circle's stroke region participates in pointer targeting.
Important Consideration
The extended SVG values should not be treated as universally supported HTML hit-testing controls. Use auto and none for predictable behavior on ordinary HTML elements.
pointer-events vs. disabled
The pointer-events property and the HTML disabled attribute serve different purposes.
CSS Pointer Targeting
.button {
pointer-events: none;
}
This prevents the button itself from being selected as a pointer target, but it does not give the button disabled semantics or automatically remove it from keyboard navigation.
HTML Disabled Attribute
<button type="button" disabled>Unavailable</button>
The HTML disabled attribute disables a supported form control and prevents normal user activation.
Comparison
| Behavior | pointer-events: none |
disabled |
|---|---|---|
| Prevents normal pointer targeting | Yes | Control-specific behavior |
| Disables form control semantics | No | Yes |
| Prevents normal keyboard activation | No | Yes |
| Removes a supported control from normal keyboard focus | No | Yes |
| Applies to ordinary decorative elements | Yes | No |
Recommended Approach
Use the native disabled attribute when a supported form control must be disabled. Use pointer-events when the goal is to control pointer hit testing.
Important Consideration
Do not rely on pointer-events: none as a security measure or a complete method of disabling an interactive element.
JavaScript Event Behavior
The pointer-events property influences pointer targeting, but it does not disable JavaScript event listeners or prevent all event propagation.
Click Event Listener
const button = document.querySelector(".demo-button");
button.addEventListener("click", function () {
console.log("Button activated");
});
When the button uses pointer-events: none, it cannot become the direct target of a pointer click. Keyboard activation or programmatic event dispatch may still invoke the listener.
Parent Event Listener
const parent = document.querySelector(".demo-parent");
parent.addEventListener("click", function () {
console.log("Event reached parent");
});
If a targetable descendant receives a click, the event may bubble to the parent even when the parent has pointer-events: none.
Restoring Pointer Targeting
const element = document.querySelector(".demo-element");
element.style.pointerEvents = "auto";
JavaScript can change the property dynamically when an interface needs to adjust pointer targeting.
Preventing Default Actions
JavaScript's event.preventDefault() and CSS pointer-events: none are different mechanisms. The former can cancel certain default event actions, while the latter changes pointer hit testing.
Important Consideration
Choose the mechanism that matches the intended behavior rather than treating CSS pointer targeting as a replacement for application interaction logic.
pointer-events Example
The following example demonstrates how a decorative overlay can allow pointer interactions to reach a button underneath it.
HTML Example
<div class="pointer-demo">
<div class="demo-panel">
<button type="button">Clickable Button</button>
<div class="demo-overlay">Overlay: pointer-events none</div>
</div>
</div>
CSS Example
.pointer-demo .demo-panel {
position: relative;
display: grid;
place-items: center;
min-height: 160px;
border: 2px solid #94a3b8;
background-color: #f1f5f9;
}
.pointer-demo button {
padding: 12px 20px;
border: 0;
background-color: #2563eb;
color: #ffffff;
cursor: pointer;
}
.pointer-demo .demo-overlay {
position: absolute;
inset: 0;
display: grid;
place-items: start center;
padding: 12px;
background-color: rgba(220, 38, 38, 0.12);
color: #991b1b;
pointer-events: none;
}
The transparent red overlay covers the panel, including the button. Because the overlay uses pointer-events: none, the button underneath remains clickable. Clicking the button changes its text to confirm that the interaction was received.
Changing the Overlay Behavior
.pointer-demo .demo-overlay {
pointer-events: auto;
}
With pointer-events: auto, the overlay can become the pointer target and intercept clicks intended for the button beneath it.
Restoring Click-Through Behavior
.pointer-demo .demo-overlay {
pointer-events: none;
}
Restoring none allows pointer targeting to pass through the decorative overlay again.
Accessibility Considerations
The pointer-events property affects pointer targeting but does not automatically make an element inaccessible or disabled.
Keyboard Navigation Remains Possible
An element with pointer-events: none may still receive keyboard focus through normal Tab navigation.
Use Native Disabled Controls
When a form control must be disabled, use the HTML disabled attribute rather than relying only on CSS.
Avoid Misleading Visual States
Do not make an interactive control appear available when pointer users cannot activate it.
Maintain Alternative Input Methods
Ensure important actions remain available through keyboard, touch, and assistive technologies where appropriate.
Decorative Overlays
Use pointer-events: none on purely decorative overlays when they would otherwise obstruct underlying interactive elements.
Screen Reader Behavior
The property does not remove an element from the accessibility tree. Use appropriate HTML semantics and accessibility attributes for the intended behavior.
Important Consideration
Pointer targeting, keyboard focus, disabled state, and accessibility semantics are separate concerns that must be handled appropriately.
Common Mistakes
Treating pointer-events as a Complete Disable Mechanism
.button {
pointer-events: none;
}
This does not provide disabled semantics or prevent every form of activation.
Assuming the Element Becomes Invisible
The property does not change visibility or opacity. Use the appropriate visual property when an element must be hidden.
Forgetting Inheritance
.parent {
pointer-events: none;
}
.child {
pointer-events: auto;
}
Descendants inherit the parent's value unless they override it. A child can restore its own pointer targeting with auto.
Expecting All JavaScript Events to Stop
Events can still propagate through an element, and keyboard or programmatic activation can still occur.
Using an Unsupported Keyword
.element {
pointer-events: disabled;
}
The value disabled is not valid for this property.
Applying SVG-Specific Values to HTML
.html-element {
pointer-events: visibleStroke;
}
Extended SVG values should not be relied upon for consistent behavior on ordinary HTML elements.
Blocking Interactive Overlays
An overlay that needs to receive pointer input should not use pointer-events: none unless its interactive descendants explicitly restore targeting.
Confusing pointer-events With touch-action
The touch-action property controls how certain touch gestures are handled, while pointer-events controls pointer hit testing.
Confusing pointer-events With user-select
The user-select property controls text selection behavior. It is not a replacement for pointer hit-testing control.
Ignoring Underlying Elements
When an element uses pointer-events: none, the interaction may reach another eligible element beneath it. Confirm that this is the intended result.
Important Considerations
Keep the following points in mind when using pointer-events:
- It controls whether an element can become a pointer event target.
- Its initial value is
auto. - The property is inherited.
- It applies to all elements.
- Its animation type is discrete.
autouses normal pointer hit-testing behavior.noneexcludes the element itself from pointer targeting.- Pointer interactions may reach eligible elements underneath an excluded element.
- The property does not hide elements or remove them from layout.
- It does not automatically remove elements from keyboard navigation.
- It does not provide disabled form-control semantics.
- It does not prevent all JavaScript events.
- Events targeting descendants can still propagate through a parent using
none. - Descendants can override inherited
nonewithauto. - It is useful for decorative click-through overlays.
- Interactive overlays must retain appropriate pointer targeting.
- SVG supports additional hit-testing values.
- SVG values can target fill, stroke, painted regions, or bounding boxes.
- Extended SVG values should not be assumed to work consistently on HTML elements.
- Use the native
disabledattribute for supported form controls that must be disabled. - Use
touch-actionwhen controlling supported touch gesture behavior. - Use
user-selectwhen controlling text selection. - Use
visibilityordisplaywhen the goal is to hide an element. - Use appropriate HTML semantics for accessibility.
- Do not rely on CSS pointer targeting as a security measure.
- Test mouse, touch, keyboard, and assistive technology interactions.
Browser Support
The CSS pointer-events property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.
The auto and none values are broadly supported for HTML elements. Additional SVG-specific values have different applicability and should be checked individually when used outside SVG.
For current compatibility information, visit Can I Use? and search for pointer-events.
Specifications
The pointer-events property is defined in CSS Basic User Interface Module Level 4, with additional SVG-specific behavior defined in SVG 2.
CSS Basic User Interface Module Level 4
SVG 2: pointer-events Property
For additional documentation and examples, consult MDN Web Docs.
