Create a disabled look of a button with CSS


To create a disabled button look, use the CSS opacity property.

Example

You can try to run the following code to create a disabled look of a button −

Live Demo

<!DOCTYPE html>
<html>
    <head>
      <style>
         .btn1 {
            color: black;
            text-align: center;
            font-size: 15px;
         }
         .btn2 {
            color: black;
            text-align: center;
            font-size: 15px;
            opacity: 0.5;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "btn1">Enabled</button>
      <button class = "btn2">Disabled</button>
   </body>
</html>

Updated on: 03-Jul-2020

251 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements