Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to radio inputs

Tags:

html

css

I'm trying to make a system which asks users to specify what kind of content they are submitting, using PNG icons to represent each type. Ideally, what I'd like is a group of three buttons (with images on them) which behave like radio buttons - the user can use arrow keys to switch between them, they are treated as one group, etcetera. However, that appears to be impossible, and the closest I can get is putting the images alongside the pre-existing radio buttons. Is there a good way to 'fake' this functionality?

like image 387
ehdv Avatar asked Dec 29 '25 07:12

ehdv


1 Answers

I would suggest using radio buttons as a user will recognise these inputs and it'll work without javascript.

<form>
<input type="radio" name="sex" value="male" id="male"/><label for="male">Male</label>
<br />
<input type="radio" name="sex" value="female" id="female" /> <label for="female">Female</label>
</form>

You can then put an image inside the labels, or better, a background image to supplement the text.

like image 87
David Snabel-Caunt Avatar answered Jan 02 '26 03:01

David Snabel-Caunt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!