HTML: Label for Checkbox in other Cell of a Table
Question by Guest | 2014-04-27 at 18:23
I have included some checkboxes on my website which are arranged using a table. The arrangement is not the problem, but I am using the label-tag and unfortunately, it is not working with the table.
When using labels outside of tables or within a table cell it is working without any problems:
<label><input type="checkbox" name="cb" value="1"> Text</label>
But as soon as trying to arrange the checkbox in another table cell than the text of the label, it is not working anymore:
<tr> <td><label><input type="checkbox" name="cb" value="1"></td> <td>Text</label></td> </tr>
So, the first example is working, the second example is not working. What can I do? For my arrangement it would be nice to divide the checkbox from the label text, but it is not working like this.
Related Topics
jQuery: Show or hide DIV-Container depending on Checkbox State
Tutorial | 0 Comments
PHP: Submit Form with many Checkboxes to Script comfortably
Tip | 2 Comments
Delphi/Lazarus: Dynamically create a Label at runtime
Tip | 0 Comments
HTML Form: Redirection depending on Radiobutton or Checkbox State
Tutorial | 0 Comments
jQuery: Toggle Checkboxes (Select/Unselect All)
Tip | 0 Comments
HTML: Preassign HTML Form with Data
Tutorial | 0 Comments
MySQL: Delete Data from Table - Difference between TRUNCATE, DELETE and DROP
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
In your case, you should use the "label for" attribute.
Here is an example:
As you can see, in this case the label-tag is only around the text. With the attribute "for", you can tell this label the ID of the checkbox, it corresponds to.
So, it is possible to separate label and checkbox like you want.
2014-04-27 at 21:55