Task 1: How to merge multiple rows using the
rowspan attribute?
Goal: Create a student directory card where a single student's name spans across multiple contact numbers vertically.
💡 Hint: Use
rowspan="2" on the
<td> containing the student's name.
💡 Show Solution
<html>
<head>
<title>Rowspan Example - AIT</title>
</head>
<body>
<h2>Student Contact Directory</h2>
<p>This table demonstrates how to merge cells vertically using the rowspan attribute.</p>
<table border="1">
<tr>
<th>Student Name</th>
<th>Contact Type</th>
<th>Phone Number</th>
</tr>
<tr>
<td rowspan="2">Sameer Joshi</td>
<td>Mobile</td>
<td>9876543210</td>
</tr>
<tr>
<td>Emergency</td>
<td>9123456780</td>
</tr>
</table>
</body>
</html>
Output :
Student Contact Directory
This table demonstrates how to merge cells vertically using the rowspan attribute.
| Student Name |
Contact Type |
Phone Number |
| Sameer Joshi |
Mobile |
9876543210 |
| Emergency |
9123456780 |
Explanation: The rowspan="2" attribute expands the name cell across 2 rows, eliminating the need to re-type the student name in the second row.
Task 2: How to combine
colspan and
rowspan in a complex table layout?
Goal: Build a schedule table featuring a full-width lunch row (
colspan) and a side title column spanning multiple session rows (
rowspan).
💡 Hint: Use
rowspan="3" for side headers and
colspan="3" for the full-width break row.
💡 Show Solution
<html>
<head>
<title>Combined Span Example - AIT</title>
</head>
<body>
<h2>AIT Tech Workshop Schedule</h2>
<table border="1">
<tr>
<th colspan="4">Day 1 Schedule Overview</th>
</tr>
<tr>
<th>Shift</th>
<th>Time</th>
<th>Topic</th>
<th>Room</th>
</tr>
<tr>
<th rowspan="2">Morning</th>
<td>09:00 AM</td>
<td>HTML5 & Table Layouts</td>
<td>Lab 101</td>
</tr>
<tr>
<td>11:00 AM</td>
<td>CSS Grid & Flexbox</td>
<td>Lab 101</td>
</tr>
<tr>
<th>Break</th>
<td colspan="3" align="center">LUNCH & NETWORKING BREAK</td>
</tr>
</table>
</body>
</html>
Output :
AIT Tech Workshop Schedule
| Day 1 Schedule Overview |
| Shift |
Time |
Topic |
Room |
| Morning |
09:00 AM |
HTML5 & Table Layouts |
Lab 101 |
| 11:00 AM |
CSS Grid & Flexbox |
Lab 101 |
| Break |
LUNCH & NETWORKING BREAK |
Explanation: Combining colspan (horizontal merging) and rowspan (vertical merging) allows you to construct complex matrix grids like timetables and reports seamlessly.