Form checkboxes not working properly with htmlfor attribute
See original GitHub issueThere are cases where DOM is dynamically generated or parsed as it happens in React or when using composable DOM elements libraries as bel.
Where this case
`<form action="#">
<p>
<input type="checkbox" id="test5" />
<label for="test5">Red</label>
</p>
</form>
`
is parsed as
<form action="#">
<p>
<input type="checkbox" id="test5" />
<label htmlfor="test5">Red</label>
</p>
</form>
this changes for attribute to htmlfor according to W3C Recommendation and getting checkbox controls not working properly.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
label not working with checkbox - Stack Overflow
I believe the label element links to the id attribute, not the name attribute. Try this: <form> <input type="checkbox" name="showRatings" id="showRatings" ...
Read more ><input type="checkbox"> - HTML: HyperText Markup Language
A Boolean attribute indicating whether this checkbox is checked by default (when the page loads). It does not indicate whether this checkbox is ......
Read more >HTML: Validating a checkbox with HTML5 - The Art of Web
While HTML5 form validation is typically about missing or invalid text inputs, there are other form element types that also require attention.
Read more >Handling Checkbox Data With In HTML: Here's How »
The <label> should always use for attribute, which specifies that it is connected to the <input> by id . This is an important...
Read more >HTML DOM Input Checkbox Object - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
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
Closed due inactivity, feel free to reopen it if it is still necessary, in that case, please provide a way to reproduce it. like a codepen.
I have the same issue with Django template, using the following code:
The checkbox and the respective label are rendering behind the submit button as seen bellow
The following works
Maybe it has something to do with the dynamic generated parts of the widgets?