pointer-events: none makes an element invisible to the pointer entirely, meaning clicks, hovers, and other pointer interactions pass straight through it as if it weren't there at all, landing instead on whatever element is positioned beneath it — this is commonly used for a decorative overlay element positioned on top of interactive content, ensuring clicks intended for that underlying content aren't accidentally intercepted by the purely visual overlay sitting above it. Unlike display: none or visibility: hidden, an element with pointer-events: none remains fully visible and still occupies its normal layout space, only its ability to actually receive and respond to pointer interactions is disabled.
1Understanding Pointer-events
pointer-events: none makes an element invisible to the pointer entirely, meaning clicks, hovers, and other pointer interactions pass straight through it as if it weren't there at all, landing instead on whatever element is positioned beneath it — this is commonly used for a decorative overlay element positioned on top of interactive content, ensuring clicks intended for that underlying content aren't accidentally intercepted by the purely visual overlay sitting above it. Unlike display: none or visibility: hidden, an element with pointer-events: none remains fully visible and still occupies its normal layout space, only its ability to actually receive and respond to pointer interactions is disabled.
pointer-events: none is the standard technique for a purely decorative overlay, like a subtle gradient or a semi-transparent icon, positioned on top of genuinely interactive content — without it, the overlay would intercept clicks intended for the interactive element positioned beneath it.
.overlay-gradient {
position: absolute;
inset: 0;
pointer-events: none;
}2Practical Example
Here is a real-world application of Pointer-events showing how it is used in production CSS code.
.icon-decoration {
pointer-events: none;
}
<button>
<span class="icon-decoration">★</span>
Favorite
</button>3Best Practices
Follow these guidelines when working with Pointer-events:
1. Use pointer-events: none on decorative overlays positioned on top of interactive content, so clicks pass through to the intended interactive element beneath
2. Remember pointer-events: none only disables pointer interaction, the element remains fully visible and still occupies its normal layout space, unlike display: none or visibility: hidden
3. Consider pointer-events: none combined with a disabled visual style as an alternative or complement to the actual disabled HTML attribute for custom interactive components
Tip: pointer-events: none is the standard technique for a purely decorative overlay, like a subtle gradient or a semi-transparent icon, positioned on top of genuinely interactive content — without it, the overlay would intercept clicks intended for the interactive element positioned beneath it.
.overlay-gradient {
position: absolute;
inset: 0;
pointer-events: none;
}