What is the <td> element in HTML?
The <td> tag stands for table data. It is used to define the data in a single cell in a table in HTML.
The
<table>tag is used to create a table. The<tr>tag is used to create a row in the header, body, or footer.
The <td> tag is used in the <tr> tag to define a single standard cell in a row. The row gets divided depending on the number of <td> tags used as a child of the <tr> tag.
Syntax
<table>
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
</tbody>
<table>
In the above snippet, a table is created using the <table> tag. There is no header or footer in this case. The body of the table is defined using the <tbody>.
The <td> must be used as a child of the <tr> tag, as shown.
Each row can have one or more data cells.
Example
The above example depicts the usage of the <td> tag.
In the above snippet, there is no header in the table. The body is defined using the <tbody>tag. In the body, there are two rows. Each row is defined using the <tr> tag.
Each row is divided into three cells using the <td> tag.
In each <td> tag, the information to be shown in the cell is written.
Free Resources