Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<th> and <td> inside <tr> Is it a legal HTML code? [closed]

Tags:

html

<table>
 <tbody>
    <tr>
    <th>Default</th>
    <td><input type="checkbox" name="checkbox" id=""></td>
  </tr>
</tbody>
</table>

This HTML code snippet is valid ?

like image 896
Praveen Avatar asked Oct 21 '22 20:10

Praveen


People also ask

Can we add TR inside TD in HTML?

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 .

Does TR tag need closing tag?

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.

What is th TD and TR in HTML?

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.

What can go inside a TD tag?

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.


1 Answers

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".

like image 71
Quentin Avatar answered Nov 04 '22 19:11

Quentin