HTML Table Colspan & Rowspan
HTML tables can have cells that span over multiple rows and/or columns.
Name | ||
---|---|---|
April | ||
---|---|---|
2022 | ||
---|---|---|
T20 WorldCup | ||
To make a cell span over multiple columns, use the colspan attribute:
Example:
<table style="width:100%">
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
Note: The value of the colspan attribute represents the number of columns to span.
HTML Table - Rowspan
To make a cell span over multiple rows, use the rowspan attribute:
To make a cell span over multiple columns, use the colspan attribute:
Example:
<table style="width:100%">
<tr>
<th colspan="2">Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>1234567890</td>
</tr>
<tr>
<td>0987654321</td>
</tr>
<tr>
<th colspan="2">Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>1234567890</td>
</tr>
<tr>
<td>0987654321</td>
</tr>
Note: The value of the rowspan attribute represents the number of rows to span.