Search⌘ K

Custom Checkbox Control

Explore how to style a native checkbox input by hiding it and replacing it with a visually appealing square checkmark using CSS only. Learn to use pseudo-elements to draw a white tick mark and change background color when selected, improving both aesthetics and accessibility.

Problem description

Given an HTML page containing a label with the class .custom-checkbox that wraps a native checkbox input, a span element with class .checkmark, and the text “Subscribe to newsletter”, write CSS to:

  • Hide the native checkbox ...