The <table> element is used to create a structured table in HTML. It allows you to organize data in rows and columns, making it easier to display information in a tabular format on a web page.
<table>
<tr>
<td>Mohan</td>
<td>Kumar</td>
</tr>
<tr>
<td>Sohan</td>
<td>Kumar</td>
</tr>
</table>
The <thead> element is used to define the header section of a table. It typically contains one or more <tr> (table row) elements that represent the column headings.
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<!-- Table data goes here -->
</tbody>
</table>
The <tbody> element is used to group the main content of a table, excluding the header and footer. It contains one or more <tr> (table row) elements that represent the table data.
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mohan</td>
<td>21</td>
</tr>
<tr>
<td>Sohan</td>
<td>23</td>
</tr>
</tbody>
</table>
The <tfoot> element is used to define the footer section of a table. It typically contains one or more <tr> (table row) elements that represent summary information or additional notes related to the table.
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<!-- Table data goes here -->
</tbody>
<tfoot>
<tr>
<td colspan="2">Table Footer</td>
</tr>
</tfoot>
</table>
The <th> element is used to define a heading cell within the table. It is typically used in the <thead> element to create column headers.
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mohan</td>
<td>21</td>
</tr>
</tbody>
</table>
The <td> element is used to define a standard data cell within the table. It is used in the <tbody> and <tfoot> elements to represent the actual data of the table.
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mohan</td>
<td>21</td>
</tr>
<tr>
<td>Sohan</td>
<td>23</td>
</tr>
</tbody>
</table>
The rowspan attribute is used to span a cell across multiple rows in a table. It specifies the number of rows a cell should occupy vertically.
<table>
<tr>
<td rowspan="2">Spanned Cell</td>
<td>Data 1</td>
</tr>
<tr>
<td>Data 2</td>
</tr>
</table>
The colspan attribute is used to span a cell across multiple columns in a table. It specifies the number of columns a cell should occupy horizontally.
<table>
<tr>
<td colspan="2">Spanned Cell</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>