How To Make Checkbox Round In Css

CSS Programming

Hey there! Today we’re going to dive into the wonderful world of CSS and explore how to make checkboxes round. Round checkboxes can add a touch of style and elegance to your website, and they’re surprisingly easy to implement.

First, let’s start with the HTML structure. We’ll use the standard input type checkbox:

<input type="checkbox" id="myCheckbox" />

Now, let’s move on to the CSS. To make our checkbox round, we’ll utilize the power of CSS pseudo-elements. Specifically, we’ll use the ::before and ::after pseudo-elements to create the circular shape.

Here’s the CSS code to make our checkbox round:

#myCheckbox {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
border: 2px solid #000;
outline: none;
cursor: pointer;

#myCheckbox:checked::before {
content: "\2713";
display: block;
width: 100%;
height: 100%;
background-color: #000;
border-radius: 50%;
text-align: center;
color: #fff;

Let’s break down this code a bit. First, we set the appearance property to none for cross-browser compatibility. Then, we specify the width and height of the checkbox, as well as the border-radius to make it round. The border property adds a border around the checkbox, and the outline property removes the default focus outline. Finally, we set the cursor property to pointer to indicate that the checkbox is clickable.

Next, we use the ::before pseudo-element to create the circular shape inside the checkbox. We set the content property to the checkmark symbol (✓), and style it with a background color, border-radius, and text color.

That’s it! With just a few lines of code, we’ve transformed our checkbox into a round shape. Feel free to experiment with different colors and sizes to match your website’s design.

In conclusion, making round checkboxes in CSS is a simple yet effective way to add some visual flair to your web forms. By leveraging CSS pseudo-elements, we can easily create stylish checkboxes that enhance the user experience. So go ahead and give it a try – your users will appreciate the attention to detail!