Skip to content

HTML Tables

HTML Tables allow you to arrange data into rows and columns on a web page, making it easy to display information like schedules, statistics, or other structured data in a clear format.

HTML Table Tags

  • <caption>- Specifies the caption (or title) of a table, providing the table an accessible description.
  • <table>- Represents tabular data—that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.
  • <thead>- Defines the header section of a table, often containing column labels.
  • <tbody>- The <tbody> HTML element encapsulates a set of table rows (<tr> elements), indicating that they comprise the body of a table’s (main) data.
  • <th>- Defines a header cell in a table.
  • <tr>- Defines a row in a table
  • <td>- Defines a cell within a table that contains data.
  • <tfoot>- Groups the footer content in a table
<table>
<caption>
HTML Table Caption
</caption>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sharma</td>
<td>24</td>
</tr>
<tr>
<td>Arun</td>
<td>32</td>
</tr>
<tr>
<td>Sam</td>
<td>41</td>
</tr>
</tbody>
</table>

What are table rowspan and colspan ?

The rowspan and colspan are the attributes of <td> tag. These are used to specify the number of rows or columns a cell should merge. The rowspan attribute is for merging rows and the colspan attribute is for merging columns of the table in HTML.

<td rowspan="2">cell data</td>
<td colspan="2">cell data</td>