Open In App

How to Change the Checked Mark Color of a Checkbox using CSS?

Last Updated : 29 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Checkboxes are commonly used on websites to enable users to make selections, such as agreeing to terms and conditions or choosing preferences. A checkbox is a small square box in forms that users can click to select or deselect an option. By default, the checkmark inside the checkbox has a basic style, which may not match your site's design.

How to Change the Checkbox Checked Mark Color

Below are some common methods that can be used to change the checkbox mark color:

1. Using appearance: none

The easiest way to change the checkbox appearance is by removing the default style using the appearance property in CSS.

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        .heading {
            color: green;
            text-align: center;
        }

        .subheading {
            text-align: center;
        }

        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        input[type="checkbox"] {
            width: 20px;
            height: 20px;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background-color: #e0e0e0;
            border: 1px solid #ccc;
            border-radius: 3px;
            cursor: pointer;
            position: relative;
            margin: 10px;
        }

        /* Change the background color when checkbox is checked */
        input[type="checkbox"]:checked {
            background-color: #4CAF50;
            border: 1px solid #4CAF50;
        }

        /* Add a check mark when checked */
        input[type="checkbox"]:checked::after {
            content: "";
            position: absolute;
            left: 5px;
            top: 1px;
            width: 6px;
            height: 12px;
            border-width: 0 3px 3px 0;
            transform: rotate(45deg);
            border-color: white;
            border-style: solid;
        }

        label {
            margin-left: 10px;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <h2 class="heading">Code World</h2>
    <h3 class="subheading">Change Checkbox Color</h3>
    <div class="container">
        <input type="checkbox" id="styled-checkbox-1">
        <label for="styled-checkbox-1">Option 1</label>

        <input type="checkbox" id="styled-checkbox-2">
        <label for="styled-checkbox-2">Option 2</label>

        <input type="checkbox" id="styled-checkbox-3">
        <label for="styled-checkbox-3">Option 3</label>

        <input type="checkbox" id="styled-checkbox-4">
        <label for="styled-checkbox-4">Option 4</label>
    </div>
</body>
</html>

Output

checkbox
How to Change the Checked Mark Color of a Checkbox using CSS?

2. Using Pseudo-Elements

A common approach is to make a custom checkbox and its checked mark by hiding the normal checkbox and using the ::before and ::after pseudo-elements. This gives us complete control over how the checked and unchecked status look.

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        .heading {
            color: green;
            text-align: center;
        }

        .subheading {
            text-align: center;
        }

        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        input[type="checkbox"] {
            width: 20px;
            height: 20px;
            appearance: none;
            -webkit-appearance: none;
            background-color: #e0e0e0;
            border: 1px solid #ccc;
            border-radius: 3px;
            cursor: pointer;
            position: relative;
        }

        input[type="checkbox"]:checked {
            background-color: #4CAF50;
            border: 1px solid #4CAF50;
        }

        input[type="checkbox"]:checked::after {
            content: "";
            position: absolute;
            left: 5px;
            top: 1px;
            width: 6px;
            height: 12px;
            border-width: 0 3px 3px 0;
            transform: rotate(45deg);
        }
    </style>
</head>
<body>
    <h2 class="heading">Code World</h2>
    <h3 class="subheading">Change Checkbox color</h3>
    <div class=" container">
        <input type="checkbox" id="styled-checkbox">
        <label for="styled-checkbox">Option 1</label>
        <input type="checkbox" id="styled-checkbox">
        <label for="styled-checkbox">Option 2</label>
        <input type="checkbox" id="styled-checkbox">
        <label for="styled-checkbox">Option 3</label>
        <input type="checkbox" id="styled-checkbox">
        <label for="styled-checkbox">Option 4</label>
    </div>
</body>
</html>

Output

Screenshot-2024-10-16-130759
How to Change the Checked Mark Color of a Checkbox using CSS?

3. Using CSS accent-color Property

This property allows you to pick a single color that will be applied to the background of the checkbox, the checked mark, and other parts of the form control.

Now, let us understand with the help of the example:

HTML
<html>
<head>
	<style>
    	.container {
        	display: flex;
	        flex-direction: column;
    	    align-items: center;
    	}

	    .heading {
    	    color: green;
        	text-align: center;
    	}

    	.subheading {
        	text-align: center;
	    }

    	input[type="checkbox"] {
        	accent-color: #4CAF50;
        	/* Green color */
    	}
	</style>
</head>
  
<body>
    <h2 class="heading">Code World</h2>
    <h3 class="subheading">Change Checkbox color</h3>
    <div class="container">
        <label>
            <input type="checkbox" id="checkbox1">
            <span class="custom-checkbox"></span> Option 1
        </label>
        <label>
            <input type="checkbox" id="checkbox1">
            <span class="custom-checkbox"></span> Option 2
        </label>
        <label>
            <input type="checkbox" id="checkbox1">
            <span class="custom-checkbox"></span> Option 3
        </label>
        <label>
            <input type="checkbox" id="checkbox1">
            <span class="custom-checkbox"></span> Option 4
        </label>
    </div>
</body>

</html>

Output

Screenshot-2024-10-16-130913
How to Change the Checked Mark Color of a Checkbox using CSS?

4. Using a Custom Background Image for the Checkbox

For a more unique and personalized checkbox design, a custom background image can be applied to the checked mark, allowing for greater flexibility and customization beyond the default styles.

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        .heading {
            color: green;
            text-align: center;
        }

        .subheading {
            text-align: center;
        }

        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        input[type="checkbox"] {
            width: 30px;
            height: 30px;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background-color: #f0a500;
            border: 2px solid #ccc;
            border-radius: 5px;
            cursor: pointer;
            position: relative;
            margin: 10px;
        }
        input[type="checkbox"]:checked {
            background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Checkmark_green.svg/1200px-Checkmark_green.svg.png');
            background-size: contain;
            background-position: center;
            background-repeat: no-repeat;
        }

        label {
            margin-left: 10px;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <h2 class="heading">Code World</h2>
    <h3 class="subheading">Change Checkbox Color Using Custom Background Image</h3>
    <div class="container">
        <input type="checkbox" id="styled-checkbox-1">
        <label for="styled-checkbox-1">Option 1</label>

        <input type="checkbox" id="styled-checkbox-2">
        <label for="styled-checkbox-2">Option 2</label>

        <input type="checkbox" id="styled-checkbox-3">
        <label for="styled-checkbox-3">Option 3</label>

        <input type="checkbox" id="styled-checkbox-4">
        <label for="styled-checkbox-4">Option 4</label>
    </div>
</body>
</html>

Output

chnage-checkbox
How to Change the Checked Mark Color of a Checkbox using CSS?

5. Using box-shadow for the Check Mark

To change the color of the checked mark without fully redesigning the checkbox, the box-shadow property can be used to create a simple and subtle effect.

Now, let us understand with the help of the example:

HTML
<html>
<head>
    <style>
        .heading {
            color: green;
            text-align: center;
        }
        .subheading {
            text-align: center;
        }
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        input[type="checkbox"] {
            width: 30px;
            height: 30px;
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background-color: #e0e0e0;
            border: 2px solid #ccc;
            border-radius: 5px;
            cursor: pointer;
            position: relative;
            margin: 10px;
        }
        input[type="checkbox"]:checked {
            background-color: #4CAF50;
            border: 2px solid #4CAF50;
            box-shadow: inset 0 0 0 4px white;
        }

        label {
            margin-left: 10px;
            font-size: 16px;
        }
    </style>
</head>
<body>
    <h2 class="heading">Code World</h2>
    <h3 class="subheading">Change Checkbox Color Using Box Shadow</h3>
    <div class="container">
        <input type="checkbox" id="styled-checkbox-1">
        <label for="styled-checkbox-1">Option 1</label>

        <input type="checkbox" id="styled-checkbox-2">
        <label for="styled-checkbox-2">Option 2</label>

        <input type="checkbox" id="styled-checkbox-3">
        <label for="styled-checkbox-3">Option 3</label>

        <input type="checkbox" id="styled-checkbox-4">
        <label for="styled-checkbox-4">Option 4</label>
    </div>
</body>
</html>

Output

Screenshot-2025-04-29-152258
How to Change the Checked Mark Color of a Checkbox using CSS?

Conclusion

Checkboxes are crucial for user selections on websites, but their default appearance may not fit the site’s design. By using CSS techniques like appearance: none, pseudo-elements, the accent-color property, custom background images, and box-shadow, the checkbox and its checked mark can be easily customized to match the site's style and improve the user experience.


Next Article

Similar Reads