How to Make a Button Unclickable using CSS?

To make a button unclickable in CSS, you can use the pointer-events property. The pointer-events property is used to control various mouse events on elements.

So, If you set the pointer-events property to none for a button, it will make it unclickable.

Let’s say we have a button with a class 'disabled' in our HTML file:

<button class="disabled">Disabled button</button>

To make it unclickable, we will set its pointer-events property to none in our CSS file:

.disabled{
    pointer-events: none;
    opacity: 0.6;
}

This is how the button will look like after applying the above styles:

Make a Button Unclickable in CSS

Thanks for reading.


Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.

    View all posts