Checkbox Input elements are inside the Label elements
See original GitHub issueGeneral information
Checkbox Input elements (both with schema elements and when choosing Properties) are generated inside the Label elements, and not after/before them as it’s normally done. This is bad semantics and produces problems when your styling relies on this fact.
- json-editor version:1.3.5
Expected behavior
Normally a label and its input element are placed next to each other as it can be seen here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox.
Actual behavior
This is what ends up getting generated in for example https://json-editor.github.io/json-editor/:
<label class="checkbox" style="display: inline-block; font-weight: normal;"> age <input type="checkbox" disabled="" style="width: auto; display: inline-block;"> </label>
Steps to reproduce the behavior
Just check the HTML code produced.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
<input type="checkbox"> - HTML: HyperText Markup Language
A checkbox allows you to select single values for submission in a form (or ... <input> elements of type checkbox are rendered by...
Read more >checkboxes inside labels? - Stack Overflow
Labels may contain inline elements (except other labels). Input elements are inline elements. imho below: Anyhow, I would not put the checkbox ......
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 >Using label elements to associate text labels with form controls
The objective of this technique is to use the label element to explicitly associate a form control with a label. A label is...
Read more >Need help with each checkbox nested in its own label element
am kinda stuck somewhere here…its requesting me to nest my checkboxes in their individual label elements which I think I have already done ......
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 FreeTop 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
Top GitHub Comments
The Materialize Theme set the
for
attribute on thelabel
tag in the functiongetFormControl
But it still wraps theinput
tag inside thelabel
tag, which is correct according to the Materialize documentation,Personally I always use the wrap method, as you don’t have to worry about
id
andfor
attributes. (less code.)From w3: The label itself may be positioned
before
,after
oraround
the associated control. Either one is valid. Wrapping thelabel
tag around theinput
tag allows you to skip thefor
attribute on thelabel
tag and theid
on theinput
tag,