Skip to main content

Lesson 2 of 8

Colspan, Rowspan & Complex Tables

Build complex table structures using colspan and rowspan to merge cells across columns and rows. Learn how to create schedules, comparison charts, and data dashboards with multi-level headers.

30 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Spanning Cells

colspan and rowspan attributes let a single cell stretch across multiple columns or rows. colspan='2' makes a cell span 2 columns; rowspan='3' spans 3 rows. These are essential for creating schedule grids, price comparison tables, and reports with grouped headers. Always ensure the total column count adds up correctly in every row - mismatched counts cause broken layouts.

Diagram
Loading diagram…

colspan stretches cells across columns; rowspan stretches cells across rows

Complex Table Example

Complex Table Example
<!-- Schedule table with spanning -->
<table>
  <caption>Weekly Class Schedule</caption>
  <thead>
    <tr>
      <th></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">9:00</th>
      <td rowspan="2">Math</td>
      <td>English</td>
      <td rowspan="2">Math</td>
      <td>English</td>
      <td>Science</td>
    </tr>
    <tr>
      <th scope="row">10:00</th>
      <td>Science</td>
      <td>Art</td>
      <td>Math</td>
    </tr>
    <tr>
      <th scope="row">11:00</th>
      <td colspan="5" style="text-align:center">Lunch Break</td>
    </tr>
    <tr>
      <th scope="row">12:00</th>
      <td>Physics</td>
      <td colspan="2">Lab Session</td>
      <td>Physics</td>
      <td>Free Period</td>
    </tr>
  </tbody>
</table>

Quick Quiz: Complex Tables

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/8 done