How to make an area unclickable with CSS?

To make an area unclickable with CSS, we can use various CSS properties. This article covers three different approaches to disable click interactions on specific areas of a webpage.

Syntax

/* Method 1: Using pointer-events */
selector {
    pointer-events: none;
}

/* Method 2: Using z-index overlay */
.overlay {
    position: absolute;
    z-index: higher-value;
}

/* Method 3: Using transparent div */
.transparent-overlay {
    position: absolute;
    background-color: transparent;
}

Method 1: Using pointer-events Property

The CSS pointer-events property controls how an element responds to pointer events such as mouse clicks, mouseovers, and mouse movements. Setting it to none makes the element unclickable

<!DOCTYPE html>
<html lang="en">
<head>
<style>
    .clickable-area {
        background-color: lightblue;
        border: 2px solid blue;
        width: 200px;
        height: 100px;
        display: block;
        text-decoration: none;
        color: black;
        text-align: center;
        line-height: 100px;
        margin: 10px;
    }
    
    .unclickable {
        pointer-events: none;
        background-color: lightgray;
        border: 2px solid gray;
    }
</style>
</head>
<body>
    <h3>Clickable vs Unclickable Areas</h3>
    <a href="/css/index.htm" class="clickable-area">Clickable Area</a>
    <a href="/css/index.htm" class="clickable-area unclickable">Unclickable Area</a>
</body>
</html>
Two rectangular areas appear: a blue clickable area that responds to mouse clicks, and a gray unclickable area that ignores all pointer events.

Method 2: Using z-index Property

The CSS z-index property defines the stacking order of positioned elements. By placing a transparent element with higher z-index over the target area, we can block clicks

<!DOCTYPE html>
<html lang="en">
<head>
<style>
    .container {
        position: relative;
        display: inline-block;
    }
    
    .link {
        background-color: lightcoral;
        border: 2px solid red;
        width: 200px;
        height: 100px;
        display: block;
        text-decoration: none;
        color: black;
        text-align: center;
        line-height: 100px;
    }
    
    .blocking-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        background-color: transparent;
    }
</style>
</head>
<body>
    <h3>Z-index Overlay Method</h3>
    <div class="container">
        <a href="/css/index.htm" class="link">Blocked by Overlay</a>
        <div class="blocking-overlay"></div>
    </div>
</body>
</html>
A red rectangular area appears that looks clickable but cannot be clicked due to the invisible transparent overlay positioned above it.

Method 3: Using Transparent Div Overlay

This approach places a transparent div element directly over the target area to intercept click events

<!DOCTYPE html>
<html lang="en">
<head>
<style>
    .wrapper {
        position: relative;
        display: inline-block;
    }
    
    .target-link {
        background-color: lightgreen;
        border: 2px solid green;
        width: 200px;
        height: 100px;
        display: block;
        text-decoration: none;
        color: black;
        text-align: center;
        line-height: 100px;
    }
    
    .transparent-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.1);
        cursor: not-allowed;
    }
</style>
</head>
<body>
    <h3>Transparent Div Overlay</h3>
    <div class="wrapper">
        <a href="/css/index.htm" class="target-link">Protected Area</a>
        <div class="transparent-overlay"></div>
    </div>
</body>
</html>
A green rectangular area appears with a slight dark overlay and a "not-allowed" cursor, indicating the area is protected from clicks.

Comparison

Method Advantages Best Use Case
pointer-events: none Simple, direct, no extra HTML Permanently disabling elements
z-index overlay Can be toggled dynamically Conditional blocking
Transparent div Visual feedback possible User interface overlays

Conclusion

The pointer-events: none method is the most straightforward approach for making areas unclickable. The overlay methods provide more flexibility for dynamic interactions and visual feedback.

Updated on: 2026-03-15T15:39:15+05:30

20K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements