table

Introduction

HTML table tag is used to create a table.
It consists of rows and columns.
<table> tag is used to create a table.
<tr> tag is used to create a row in a table.
<td> tag is used to create a cell in a row.
<th> tag is used to create a header cell in a row.

Basic structure of a table:
<table>
  <tr>
    <th>Header1</th> <th>Header2</th>
  </tr>
  <tr>
    <td>Data</td> <td>Data</td>
  </tr>
</table>

Output:
Header1 Header2
Data Data

span

Span in table is used to merge cells.

Colspan attribute is used to merge cells horizontally.
<table>
  <tr>
    <th colspan="2">Header1</th>
  </tr>
  <tr>
    <td>Data</td> <td>Data</td>
  </tr>
</table>

Output:
Header1
Data Data

Rowspan attribute is used to merge cells vertically.
<table>
  <tr>
    <th rowspan="2">Header1</th> <th>Header2</th>
  </tr>
  <tr>
    <td>Data</td> <td>Data</td>
  </tr>
</table>

Output:
Header1 Header2
Data Data