I have 5 checkboxes and a table with 6 rows (1 head, 5 body), representing choices for a question. How can I align each checkbox with the first line of each row in the table?
table,
thead,
td {
border: 1px solid black;
padding: 3px;
}
thead {
font-weight: bold !important;
}
table {
margin: 5px;
margin-bottom: 1rem;
}
.form-check {
margin-left: -20px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<p style="margin-left: 20px;">
<form id='f1'>
<div class='form-check'><input type='checkbox' class='form-check-input' name='A'></div>
<br>
<div class='form-check'><input type='checkbox' class='form-check-input' name='B'></div>
<br>
<div class='form-check'><input type='checkbox' class='form-check-input' name='C'></div>
<br>
<div class='form-check'><input type='checkbox' class='form-check-input' name='D'></div>
<br>
<div class='form-check'><input type='checkbox' class='form-check-input' name='E'></div>
</form>
<table>
<thead>
<tr>
<td> </td>
<td>Event 1</td>
<td>Event 2</td>
<td>Event 3</td>
<td>Event 4</td>
</tr>
</thead>
<tbody>
<tr>
<td>a)</td>
<td>29</td>
<td>29</td>
<td>30</td>
<td>30</td>
</tr>
<tr>
<td>b)</td>
<td>29</td>
<td>30</td>
<td>30</td>
<td>31</td>
</tr>
<tr>
<td>c)</td>
<td>30</td>
<td>30</td>
<td>31</td>
<td>31</td>
</tr>
<tr>
<td>d)</td>
<td>30</td>
<td>31</td>
<td>31</td>
<td>31</td>
</tr>
<tr>
<td>e)</td>
<td>31</td>
<td>31</td>
<td>31</td>
<td>31</td>
</tr>
</tbody>
</table>
</p>
I'm not very knowledgeable about CSS, but after experimenting with developer tools, I managed to align the form alongside the table as seen in this image. However, the checkboxes start below the table due to the use of line breaks. Placing the checkboxes inside the cells would disrupt the styling.