Step 1: HTML
Step 2: Hide radio buttons
To hide radio buttons there are few options such as display or visibility or opacity CSS properties. Using opacity is a better option for a11y.
But, that will leave the space for the element on the page so what you can do is set the position for radio buttons to absolute.
Step 3: Make images clickable
Radio buttons you can select automatically. With image being the face of the radio buttons, we need to make images clickable.
The trick is to set the cursor property value to pointer.
We can use adjacent sibling combinator (+) to select an img element that is directly after the input radio.
At the same time, let’s add some margin-right to add space between the images.
Step 4: Make selection visible
As you can see the radio buttons are getting clicked but the clicks are not visible. Let’s add a CSS rule for :checked radio buttons.
buttons examples images radio style