Build a class schedule with merged cells
Task
The starter page is a course schedule built as a flat table: double classes are written twice, the lunch break is repeated in every cell, and there are no headers or caption. Rebuild the table so repeated cells become merged cells, and headers and the note become proper table structure.
Requirements
- The table has a <caption> with its title
- Day names are <th scope="col"> cells inside <thead>
- Every time slot row in <tbody> starts with a <th scope="row">
- The double classes (HTML basics on Monday and Thursday) take two rows with rowspan="2"
- The lunch break spans all five days (colspan="5"), and the two-day team project spans two (colspan="2")
- The note about breaks is in <tfoot>, in one cell that spans the full width of the table
- Once merged cells are counted, every row has the same number of columns
Starter code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Class schedule</title>
</head>
<body>
<h1>Class schedule</h1>
<table>
<tr>
<td>Time</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td>
</tr>
<tr>
<td>09:00</td><td>HTML basics</td><td>CSS</td><td>JavaScript</td><td>HTML basics</td><td>Code review</td>
</tr>
<tr>
<td>10:30</td><td>HTML basics</td><td>Git</td><td>Accessibility</td><td>HTML basics</td><td>Q&A</td>
</tr>
<tr>
<td>12:00</td><td>Lunch break</td><td>Lunch break</td><td>Lunch break</td><td>Lunch break</td><td>Lunch break</td>
</tr>
<tr>
<td>13:00</td><td>Practice</td><td>Team project</td><td>Team project</td><td>Practice</td><td>Test</td>
</tr>
</table>
<p>Breaks between classes: 10 minutes.</p>
</body>
</html>
▶ Open in HTML Editor Hints
- A cell with rowspan="2" also takes the same column in the next row, so that row gets one <td> less for that day.
- colspan merges cells to the right: one cell with colspan="5" replaces five separate "Lunch break" cells.
- scope="col" marks a header for a column and scope="row" a header for a row; screen readers use it to read each cell together with its headers.
- <caption> must be the first element inside <table>.
- Check your table in the HTML Validator: it warns when a row ends up wider than the header row and reports an error when a merged cell stretches past the last column.
Show solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Class schedule</title>
</head>
<body>
<h1>Class schedule</h1>
<table>
<caption>Web development course, week 1</caption>
<thead>
<tr>
<th scope="col">Time</th>
<th scope="col">Monday</th>
<th scope="col">Tuesday</th>
<th scope="col">Wednesday</th>
<th scope="col">Thursday</th>
<th scope="col">Friday</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">09:00</th>
<td rowspan="2">HTML basics</td>
<td>CSS</td>
<td>JavaScript</td>
<td rowspan="2">HTML basics</td>
<td>Code review</td>
</tr>
<tr>
<th scope="row">10:30</th>
<td>Git</td>
<td>Accessibility</td>
<td>Q&A</td>
</tr>
<tr>
<th scope="row">12:00</th>
<td colspan="5">Lunch break</td>
</tr>
<tr>
<th scope="row">13:00</th>
<td>Practice</td>
<td colspan="2">Team project</td>
<td>Practice</td>
<td>Test</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="6">Breaks between classes: 10 minutes.</td>
</tr>
</tfoot>
</table>
</body>
</html>
Related tools
HTML Editor Online
Write HTML with syntax highlighting and line numbers, see a live preview, format or minify it, and open or save .html files — all in your browser.
Build a data table
Practice exercise: build a table with correct thead/tbody structure for tabular data.
Tables
The table, thead, tbody, tr, th, td structure for tabular data.
The <table> tag
Table structure: thead, tbody, tr, th, td. Example and practical notes.
HTML Table Generator
Quickly generate HTML table markup with a given number of rows and columns.
Responsive table
An overflow-x:auto wrapper for horizontal table scrolling on narrow screens.
HTML Validator
Check HTML for unclosed tags, duplicate ids, and other errors with the Nu Html Checker. Your code is sent to our server for checking.