CSS pointer-events Property

You are Here:

CSS pointer-events Property

CSS pointer-events property defines whether or not an element reacts to pointer events.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> a{ display: block; margin: 10px; } a:nth-child(2){ pointer-events: none; } a:nth-child(3){ pointer-events: auto; } </style> </head> <body> <h1>CSS pointer-events Property</h1> <a href="#">Hover me, I'm pointer event none.</a> <a href="#">Hover me, I'm pointer event auto.</a> </body> </html>

Syntax

Using CSS

element{ pointer-events: none; }

Using Javascript

object.style.pointerEvents="none";

Animatable

No, pointer-events property is not animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS pointer-events property is auto.

Property Value

The following table provides a list of values for CSS pointer-events property.

ValueExplanation
noneSpecifies that the element is never the target of pointer events; however, pointer events may target its descendant elements if those descendants have pointer-events set to some other value.
autoSpecifies that the element behaves as it would if the pointer-events property were not specified.

Using JavaScript

In the following example, we will demonstrate how to change the CSS pointer-events property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>CSS pointer-events Property</h1> <a href="#">Hover me before and after clicking on the button.</a> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("a")[0]; function myFunction(){ x.style.pointerEvents = "none"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author