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

Syntax
form { accent-color: #1d4ed8; }

Example

Interactive preview available
forms.css
form {
  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

  1. The form sets one accent color.
  2. Checkboxes and radios inherit it.
  3. The range input uses the same color.
  4. Labels stay flex rows with a small gap.
  5. You do not redraw the checkbox.
  6. The control remains a real input.
  7. A dark page may need a lighter accent.
  8. 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.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…