How to style round buttons with CSS?


To make round buttons, the border-radius property plays a key role. Set it to 50% and that’s it. It will convert the shape to rounded. To set multiple buttons, use the display property with the value block. This will arrange them. Also, if you want to change the style on hover, then use the :hover selector. Let us see how to style round buttons with HTML and CSS.

Create a button shape

Create links using the <a> element and make it look like buttons −

<a href="#" class="btn1">50%</a>
<a href="#" class="btn2">50%</a>

Text decoration none

The text-decoration property is set to none to avoid the links getting underlines because we need to shape it like a rounded button −

a {
   text-decoration: none;
   display: inline-block;
   padding: 18px;
   font-size: 35px;
   width: 60px;
   height: 60px;
   text-align: center;
}

Rounded buttons

The shape is changed to rounded using the border-radius property −

.btn1 {
   border-radius: 50%;
   background-color: #acacac;
   color: black;
}
.btn2 {
   border-radius: 50%;
   background-color: rgb(68, 30, 112);
   color: white;
}

Hover the rounded buttons

The :hover selector is used to hover the rounded buttons shape. On hover the background and text color are changed −

.btn1:hover {
   background-color: #ddd;
   color: black;
}
.btn2:hover {
   background-color: rgb(121, 37, 133);
   color: white;
}

Example

The following is the code to style round buttons with CSS −

<!DOCTYPE html>
<html>
<head>
   <style>
      a {
         text-decoration: none;
         display: inline-block;
         padding: 18px;
         font-size: 35px;
         width: 60px;
         height: 60px;
         text-align: center;
      }
      .btn1:hover {
         background-color: #ddd;
         color: black;
      }
      .btn2:hover {
         background-color: rgb(121, 37, 133);
         color: white;
      }
      .btn1 {
         border-radius: 50%;
         background-color: #acacac;
         color: black;
      }
      .btn2 {
         border-radius: 50%;
         background-color: rgb(68, 30, 112);
         color: white;
      }
   </style>
</head>
<body>
   <h1>Style round Button Example</h1>
   <a href="#" class="btn1">50%</a>
   <a href="#" class="btn2">50%</a>
</body>
</html>

Updated on: 21-Dec-2023

189 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements