Style CSS checkboxes with accent-color and appearance
Use accent-color if you only need to tint a checkbox. To draw the border and check mark, apply appearance: none to a real <input type="checkbox"> and style its checked and focus states. Keep a descriptive label with either approach.
Choose between changing the color and drawing the control
input[type="checkbox"] {
accent-color: #176b86;
}
accent-color colors supported native controls. The browser and operating system may still choose details of the appearance. Use appearance when you need control over the border and check mark. This example keeps the input visible and focusable. See CSS UI Level 4 · accent-color and CSS UI Level 4 · appearance.
Try a complete native and custom checkbox example
Save the example as checkbox.html and open it. No separate images or JavaScript are needed. The first option uses the native control. The second and third draw the check mark with an SVG in the CSS.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Checkboxes with keyboard controls</title>
<style>
body { margin: 20px; font: 16px/1.6 system-ui, sans-serif; color: #203348; }
* { box-sizing: border-box; }
h1 { font-size: 24px; }
form { max-width: 480px; }
.option { display: flex; align-items: center; gap: 10px;
min-height: 44px; cursor: pointer; }
.option input { flex: none; margin: 0; }
.native { width: 20px; height: 20px; accent-color: #176b86; }
.custom { appearance: none; width: 20px; height: 20px;
border: 2px solid #4d6578; border-radius: 4px;
background: white; cursor: pointer; }
.custom:checked { border-color: #176b86; background-color: #176b86;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8 6 11 13 4' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E");
background-position: center; background-repeat: no-repeat; background-size: 16px; }
input:focus-visible { outline: 3px solid #b95700; outline-offset: 3px; }
.disabled { cursor: default; color: #647380; }
.custom:disabled { opacity: 0.55; cursor: not-allowed; }
button { margin-top: 12px; min-height: 44px; padding: 8px 16px; font: inherit; }
@media (forced-colors: active) {
.custom, .custom:checked {
appearance: auto;
background: revert;
border: revert;
}
.custom:disabled { opacity: 1; }
}
</style>
</head>
<body>
<h1>Compare checkbox styles</h1>
<form method="get">
<label class="option" for="news">
<input class="native" type="checkbox" id="news" name="news" value="yes">
<span>Receive updates · native style</span>
</label>
<label class="option" for="terms">
<input class="custom" type="checkbox" id="terms" name="terms" value="yes" required>
<span>Accept terms · custom style</span>
</label>
<label class="option disabled" for="locked">
<input class="custom" type="checkbox" id="locked" checked disabled>
<span>This selection cannot be changed</span>
</label>
<button type="submit">Check submitted values</button>
</form>
</body>
</html>
Click the label text to toggle either of the first two options. Reach them with Tab and toggle with Space. The third option is disabled, so it stays checked and ordinary Tab navigation skips it.
Keep checked, focus, and forced-colors states clear
The custom control uses :checked for its fill and check mark and :focus-visible for an outline. A label’s for must match a unique input id. Keep a shape such as the check mark visible so that color alone does not convey the state.
In forced-colors mode, the example restores appearance: auto for both the unchecked and checked control and resets the custom background and border. This lets the system draw the check mark. To practice changing the accent, replace #176b86 with #7546a3, check that the labels and focus still work, and restore the original value. See CSS Color Adjustment · Forced colors.
Check required fields and submitted values
Submit with the second option unchecked to see required validation. If you check only that option and submit, the address includes terms=yes. Check the first option as well and submit again to add news=yes.
The form submits the name and value of checked, enabled inputs. An unchecked or disabled checkbox is generally omitted, so server code needs to handle absence. The sample uses GET to reopen the current document with its values in the address. See HTML Standard · Checkbox.




