HTML Table Colspan & Rowspan
Table cells can span over more than one row and/or column.
HTML Table - Colspan
To make a cell span several columns, use the colspan attribute.
Note: The value of colspan is the number of columns to span.
Example
A header cell that spans two columns.
Prompt
A table where a Name header spans two columns using colspan=2, plus an Age header, then two data rows (Jill Smith 43, Eve Jackson 57).
Output: complete HTML page
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Colspan</title>
</head>
<body>
<table>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>43</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>57</td>
</tr>
</table>
</body>
</html>
HTML Table - Rowspan
To make a cell span several rows, use the rowspan attribute.
Note: The value of rowspan is the number of rows to span.
Example
A cell that spans two rows.
Prompt
A table where a Phone header spans two rows using rowspan=2, with a Name row (Jill) and two phone numbers (555-1234 and 555-8745).
Output: complete HTML page
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rowspan</title>
</head>
<body>
<table>
<tr>
<th>Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>555-1234</td>
</tr>
<tr>
<td>555-8745</td>
</tr>
</table>
</body>
</html>