Home > Blockchain >  How to insert multiple checkbox horizontally in one table cell?
How to insert multiple checkbox horizontally in one table cell?

Time:04-20

I am learning HTML and I wonder if I can insert multiple checkbox in a single table cell. I can only create one checkbox in a table cell right now. Below is an example of my code.

<td colspan="2" rowspan="1" ><input type="checkbox" name="7_4" value="7_4" /> M</td>

CodePudding user response:

You can any number of checkboxes as you want:

<td colspan="2" rowspan="1" >
<input type="checkbox" name="7_4" value="7_4" /> M
<input type="checkbox" name="7_5" value="7_5" /> N
<input type="checkbox" name="7_6" value="7_6" /> O
</td>

But try to give them a unique name and value.

CodePudding user response:

you can add as many checkbox as you need in a cell, and they take place horizontally beside each other as default! also you should use label tag for the labels... enjoy the journey!

<td colspan="2" rowspan="1">
      <input type="checkbox" id="M" name="7_4" value="7_4"> 
      <label for="M"> M </label>
      <input type="checkbox" id="N" name="7_5" value="7_5">
      <label for="N"> N </label>
      <input type="checkbox" id="O" name="7_6" value="7_6">
      <label for="O"> O </label>
      <input type="checkbox" id="P" name="7_7" value="7_7">
      <label for="P"> P </label>
</td>

CodePudding user response:

Yes you can

<td colspan="2" rowspan="1">
    <input type="checkbox" name="7_4" value="7_4"> M </input>
    <input type="checkbox" name="7_4" value="7_4"> M </input>
    <input type="checkbox" name="7_4" value="7_4"> M </input>
</td>

  •  Tags:  
  • html
  • Related