<table>
<tbody>
<tr>
<th>Default</th>
<td><input type="checkbox" name="checkbox" id=""></td>
</tr>
</tbody>
</table>
This HTML code snippet is valid ?
You cannot put tr inside td. You can see the allowed content from MDN web docs documentation about td . The relevant information is in the permitted content section. Another way to achieve this is by using colspan and rowspan .
According to w3c </TD> and </TR> tags are optional, so the following table is perfectly valid. And all browsers I've tested it with render the table fine.
An HTML table consists of one <table> element and one or more <tr>, <th>, and <td> elements. The <tr> element defines a table row, the <th> element defines a table header, and the <td> element defines a table cell.
The <td> tag can contain text, form, image, table etc. The content inside it is left-aligned by default. If you present tabular data in tables than each data cell must be added individually as a <td> element.
There is nothing invalid about a table row containing both table heading and table data cells. Semantically, this would usually make sense only if the headings were scope="row"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With