Jump to content
metemaddar

Labels should be in inputs for option buttons

Recommended Posts

For option buttons, when we click on labels, the option buttons should be selected. In order to achieve this, We need to put input inside labels.

For example instead of write this:

<input class="w3-check" type="checkbox" checked="checked">
<label>Milk</label>
We should write this:
<label>
<input class="w3-check" type="checkbox" checked="checked">
Milk</label>

Now when we click on CheckBox's label the checkbox gets checked.

This is the same for option button.

We can change this in html tutorials and w3.css tutorials too. like here.

Again thanks a lot for fantastic website. I've learned everything about web, First from W3Schools.

Chears.

 
Edited by metemaddar

Share this post


Link to post
Share on other sites

Actually what you can do is give the input a id reference and use attribute 'for' in the label with the value of the id ref to link them and do the same as placing input within a label.

<label for="male">Male</label>
  <input type="radio" name="gender" id="male" value="male"><br>

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...