πŸŽ„ Get 20% off from our JavaScript course for the holidays! πŸŽ„
πŸ’‘ This page contain affiliate links. By making a purchase through them, we may earn a commission at no extra cost to you.
How to Prevent Elements Receiving Click Events With CSS

How to Prevent Elements Receiving Click Events With CSS

Ferenc Almasi β€’ 2020 November 30 β€’ Read time 1 min read
  • twitter
  • facebook
CSS

Simply set none for pointer-events in CSS, if you want to avoid receiving click events for an element or you want it to be click-through:

Copied to clipboard!
.no-click {
    pointer-events: none;
}
no-click-events.css

This comes especially useful if you have decorative elements covering another element that should receive click events. By using the above property, you can make sure that the click goes right through the element.

How to prevent elements receiving click events using CSS
If you would like to see more Webtips, follow @flowforfrank

10 Best Practices for Quickly Improving Your CSS

Resources:

Did you find this page helpful?
πŸ“š More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Access exclusive interactive lessons
  • check Unlimited access to hundreds of tutorials
  • check Remove ads to learn without distractions
Become a Pro

Courses

Recommended