CSS3
Beginner
Modern Layout
· 6 min read
CSS accent-color for Form Controls
Lesson 29 of 41 in the CSS3 learning path.
How do I tint checkboxes and range inputs to match the catalog?
accent-color tints native form controls without replacing them with custom widgets.
Native controls stay accessible. You only change the highlight color.
Syntax & Parameters
form { accent-color: #1d4ed8; }
Example
Interactive preview availableform {
accent-color: #1d4ed8;
font: 1rem sans-serif;
}
label {
display: flex;
gap: .4rem;
margin: .4rem 0;
}
input[type="range"] {
width: 12rem;
}
Expected Output
Checked boxes and the range thumb use blue instead of the default system blue or green.
Line-by-Line Walkthrough
- The form sets one accent color.
- Checkboxes and radios inherit it.
- The range input uses the same color.
- Labels stay flex rows with a small gap.
- You do not redraw the checkbox.
- The control remains a real input.
- A dark page may need a lighter accent.
- Do not remove the focus outline when you tint the control.
Common Pitfalls & Security
accent-color tints native form controls without replacing them with custom widgets.
- accent-color does not style text inputs.
- A low contrast accent fails on a dark form.
- Replacing the checkbox with a div loses the keyboard.
- The property is ignored by very old browsers, which keep the system color.
Best Practices & Modern Standards
Set accent-color on the form so every control matches.
Keep the native control. Add a focus style separately.
Real-World Use
The enrollment form checks "email me" with a box that matches the catalog blue.
Frequently Asked Questions
Which controls does it affect?
Checkboxes, radios, and range inputs. Not text fields.
Does it replace the checkbox?
No. It only tints the native control.
What about focus?
Style focus-visible separately. Accent color is not an outline.
Can each control differ?
Yes. Set accent-color on the input that should differ.