Which attribute to use to make the entire area of a checkbox selectable?

Asked

Viewed 36 times

0

I want to make the "sample text" of the code:

<label for=valueexemplo>
<input type=checkbox value=valueexemplo>Texto de Exemplo
</label

keep the entire selectable text area, as if you were clicking on the checkbox itself, but clicking on the text.

  • 1

    The attribute for tag label gets a id of the element and not a value, that’s the problem, correct: <label for="valueexemplo">&#xA;<input type=checkbox id="valueexemplo">Texto de Exemplo&#xA;</label> ... View documentation

1 answer

1


The 'FOR' you used solves your problem, just need to write it straight.
The idea is that you have in your checkbox an ID that when the user clicks on the label it points via the FOR, to the checkbox ID that will be called.


<input type="checkbox" id="opcao" name="check" checked>
<label for="opcao">Opção</label>


See more here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/checkbox

Browser other questions tagged

You are not signed in. Login or sign up in order to post.