Checkbox inside <label>
See original GitHub issueIt would be great if checkbox can be made like this :
<label>
<input type="checkbox" />
<span>Check this</span>
</label>
The above code is similar to how switches are made :
<div class="switch">
<label>
<input type="checkbox" />
<span class="lever"></span>
</label>
</div>
I suggest to remove the current way of making checkboxes and use it under a label
tag. Current approach :
<input type="checkbox" id="test5" />
<label for="test5">Red</label>
Pros
- Less confusing (both switch and checkbox will use same approach)
- No need of
id
tag andfor
tag. Theid
tag is important and cannot be wasted as you can scroll to a section of page with it (http://exampl.com/index.html#test5
)
There maybe more pros, but I can’t think of any cons 😉
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top Results From Across the Web
checkboxes inside labels? - Stack Overflow
Screen readers will read the associated label content when its user focus on a form element (input, select or textarea). When in a...
Read more >How to create an HTML checkbox with a clickable label?
Using checkbox inside label tag: <!DOCTYPE html>. < html >. < head >. < title > · Using the for attribute: Create a...
Read more >How to Create Checkbox with a Clickable Label - W3docs
It is possible to create a checkbox with a clickable label. In this snippet, you can see how to create a checkbox with...
Read more >Checkbox with input field inside label
Hi, I have some checkboxes with the <input> inside the <label> ( e.g. the 'Create Account' button on (logged out) Woocommerce Checkout page)....
Read more >Input checkboxes wrapped inside <labels> - UX Stack Exchange
Wrap the label around the checkbox. This makes it much easier to click the button. If the label is separate from the control,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, I have made a mistake here. Thanks for pointing that out 😃
I agree this is a good change. Will add this in a future version.