The Wayback Machine - https://web.archive.org/web/20250404170150/https://www.geeksforgeeks.org/css-pointer-events-property/
Open In App

CSS pointer-events Property

Last Updated : 28 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

This property is used to specify whether an element shows pointer events and whether or not show on the pointer.

Syntax:  

pointer-events: auto|none;

Default Value: auto

Property values:  

  • auto: This property is used to specify that an element must react to pointer events.
  • none: This property is used to specify that an element does not react to pointer events.

Example: In this example, we use pointer-events: auto; property.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS | pointer-events Property
    </title>
    <style>
        p.geeks {
            pointer-events: auto;
        }
        
        h1,
        h2 {
            color: green;
        }
        
        body {
            text-align: center;
        }
    </style>
</head>

<body>
    <CENTER>
        <h1>GeeksForGeeks</h1>
        <h2>pointer-events:auto;</h2>
        <p class="geeks">
            <a href="#">GeeksforGeeks </a>
        </p>
    </CENTER>
</body>

</html>


Output: 

Example: In this example, we are using pointer-events: none; property.

html
<!DOCTYPE html>
<html>
<head>
    <title>
        CSS | pointer-events Property
    </title>
    <style>
        p.geeks {
            pointer-events: none;
        }

        h1,
        h2 {
            color: green;
        }

        body {
            text-align: center;
        }
    </style>
</head>

<body>
    <h1>GeeksForGeeks</h1>
    <h2>pointer-events:none;</h2>
    <p class="geeks">
        <a href="#">GeeksforGeeks</a>
    </p>
</body>
</html>

Output: 

Supported Browsers: The browsers supported by pointer-events Property are listed below: 

  • Google Chrome 1.0
  • Edge 12.0
  • Internet Explorer 11.0
  • Firefox 1.5
  • Opera 9.0
  • Safari 4.0

CSS pointer-events Property – FAQs

What does the pointer-events property do in CSS?

The pointer-events property in CSS specifies under what circumstances (if any) a particular graphic element can become the target of mouse events. It can control whether an element should respond to mouse events or not.

How do I disable mouse events for a specific element?

To disable mouse events for an element, use: pointer-events: none;. This setting will make the element ignore all mouse events, such as clicks, hovers, and drag actions.

What values are available for pointer-events?

The pointer-events property values include auto, none, visiblePainted, visibleFill, visibleStroke, visible, painted, fill, stroke, all, and inherit, each affecting how mouse events are handled by the element.

Can pointer-events be used to control interactions on touch devices?

Yes, pointer-events also affect interactions on touch devices by determining if an element responds to touch actions like taps or swipes.

How does pointer-events affect child elements?

If an element has pointer-events: none;, it disables mouse events for itself and its child elements unless those child elements have a different pointer-events value explicitly set.



Next Article

Similar Reads

three90RightbarBannerImg