::checkmark CSS Pseudo Element
Description
The ::checkmark pseudo-element is a specialized CSS construct primarily used in conjunction with custom checkboxes and radio buttons to style the visual indicator that signifies selection. It allows developers to separate the design of the check indicator from the actual input element of type checkbox or radio, giving complete control over the appearance without altering the underlying form functionality. Unlike standard pseudo-elements like ::before or ::after, ::checkmark is intended specifically for the interactive state of selectable form elements, making it a key tool in custom form UI design.
This pseudo-element is often paired with a container element, such as a label, that wraps the checkbox or radio input. Developers can apply styles to ::checkmark to change its size, shape, color, or transitions, reflecting states like hover, focus, or checked. For instance, background-color, border-radius, and box-shadow are commonly used to create appealing visual effects.
A typical example of ::checkmark usage is as follows:
<label class="custom-checkbox">
Accept Terms
<input type="checkbox">
<span class="checkmark"></span>
</label>
.custom-checkbox {
position: relative;
padding-left: 25px;
cursor: pointer;
user-select: none;
}
.custom-checkbox input {
position: absolute;
opacity: 0;
cursor: pointer;
}
.custom-checkbox .checkmark {
position: absolute;
top: 0;
left: 0;
height: 20px;
width: 20px;
background-color: #eee;
border-radius: 4px;
}
.custom-checkbox input:checked ~ .checkmark {
background-color: #2196F3;
}
.custom-checkbox .checkmark::checkmark {
content: "";
position: absolute;
left: 6px;
top: 2px;
width: 6px;
height: 12px;
border: solid white;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
In this example, ::checkmark is used to render the check symbol inside the styled checkbox. It provides a flexible way to control the appearance of selection without touching the actual input element. This pseudo-element is particularly useful when creating fully custom checkboxes and radio buttons that maintain accessibility while offering modern, interactive designs.
The ::checkmark pseudo-element also supports animation and transitions, allowing smooth appearance changes when a checkbox is toggled. Combined with transition or transform, it can produce professional, user-friendly effects that enhance the overall user experience.
Syntax
::checkmark {
/* ... */
}
Example
Browser Support
The following information will show you the current browser support for the CSS ::checkmark pseudo element. Hover over a browser icon to see the version that first introduced support for this CSS psuedo element.
This psuedo element is supported in some modern browsers, but not all.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 31st December 2025
