HTML Colspan & Rowspan Guide

Learn how to create complex table layouts using colspan and rowspan attributes

Introduction to Colspan & Rowspan

The colspan and rowspan attributes allow table cells to span multiple columns or rows, enabling you to create more complex and visually appealing table layouts. These attributes are essential for creating headers that span multiple columns, vertical labels, and merged cells in data tables.

Basic Examples

Basic Colspan

Header spanning multiple columns

Employee Details
John Doejohndoe@example.com

Basic Rowspan

Cell spanning multiple rows

DepartmentEmployees
25

Combined Example

Using both colspan and rowspan together

NameContact
EmailPhone
John Doejohn@example.com555-1234

Advanced Examples

Complex Layout

Advanced table with multiple spans

ProductQuarterly Sales
Q1Q2Q3
Laptops$120,000$135,000$150,000
Total: $405,000

Schedule Table

Timetable with row and column spans

TimeMondayTuesdayWednesday
9:00-11:00MathScience LabHistory
PhysicsGeography
11:00-12:00Break

Accessibility Tips

Accessible Complex Tables

Using scope, headers, and ARIA attributes

Monthly Budget
CategoryJanuaryFebruary
Income$5,000$5,200
Expenses
Rent$1,200$1,200
< PreviousNext >