How to select a radio by clicking the text next to it?

3

It's quite simple to make radio buttons. I've seen inputs of that genre out there that allow you to click directly inside the circle or above the text that refers to each radio button.

How do you do this?

    
asked by anonymous 24.06.2014 / 02:51

1 answer

3

Just put the text inside an <label> element point to the corresponding input ID:

<input type="radio" name="cores" id="vermelho"><label for="vermelho">vermelho</label>
<input type="radio" name="cores" id="verde"><label for="verde">verde</label>
<input type="radio" name="cores" id="azul"><label for="azul">azul</label>
    
24.06.2014 / 05:10