CSS - disabled button

0 points
Created by:

In this article, we would like to show you how to create a disabled button using CSS.

Quick solution:

.disabled-button {
  opacity: 0.75;
  cursor: not-allowed;


Practical example

In this example, we create a style for the disabled button by changing it's opacity and cursor. Notice that it doesn't disable the button's event handler, you have to remove its onclick attribute.

// ONLINE-RUNNER:browser;

<!doctype html>

    button {
      height: 50px;
      margin: 0 0 0 25px;

    .disabled {
      opacity: 0.75;
      cursor: not-allowed;

    function handleClick(){
      console.log('Button clicked...');
  <button class="disabled">Disabled</button>
  <button onclick="handleClick()">Enabled</button>
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂