The following code use a script to toggle/uncheck a radio when clicked a second time on the same.
My question is how do I do this using CSS only?
The answer is you can't unselect or uncheck a radio button in CSS only, as the radio button only becomes unchecked once you click on a different radio button. As only one radio button can be active at once, this will uncheck the previously checked radio button.
input:checked + label {
color: green;
}
input:not(:checked) + label {
color: red;
}
So you'll have to stick with using the JS function you posted.
Here are a couple of nice articles with further explanation :
CSS Click Events
How To Generate CSS Click Events