question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checkbox inside <label>

See original GitHub issue

It 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 and for tag. The id 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tomscholzcommented, Apr 3, 2017

Sorry, I have made a mistake here. Thanks for pointing that out 😃

1reaction
Dogfalocommented, Oct 15, 2016

I agree this is a good change. Will add this in a future version.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found