What if you could make one table cell cover many rows without copying or deleting anything?
Why Row spanning in Tailwind? - Purpose & Use Cases
Imagine you are creating a schedule table by hand. You want one event to cover two rows because it lasts longer, so you try to merge cells by copying and pasting content multiple times.
Manually merging cells means you have to delete or hide repeated cells carefully. It's easy to make mistakes, the table looks messy, and changing the layout later is a headache.
Row spanning lets you tell the browser to make one cell stretch across multiple rows automatically. This keeps your table clean, easy to read, and simple to update.
Event 1 | Time 1 Event 1 | Time 2 Event 2 | Time 3
<td rowspan="2">Event 1</td> | Time 1 | Time 2 <td>Event 2</td> | Time 3
You can create neat, organized tables that clearly show events or data spanning multiple rows without extra work.
Think of a school timetable where a class lasts two periods. Row spanning lets that class name cover both periods in the table, making the schedule easy to understand.
Manual cell merging is slow and error-prone.
Row spanning automatically stretches cells across rows.
It makes tables clearer and easier to maintain.
Practice
row-span-3 do inside a grid container?Solution
Step 1: Understand the
This class controls how many rows a grid item covers vertically.row-span-{n}classStep 2: Apply
The number 3 means the item will cover 3 rows in the grid layout.row-span-3meaningFinal Answer:
Makes the grid item span 3 rows vertically. -> Option AQuick Check:
row-span-3 = span 3 rows [OK]
- Confusing row-span with column-span
- Thinking it adds padding or margin
- Assuming it sets fixed height
Solution
Step 1: Recall Tailwind's row spanning syntax
The correct format uses a dash:row-span-{number}.Step 2: Check each option
Onlyrow-span-2matches the correct syntax for spanning 2 rows.Final Answer:
row-span-2 -> Option BQuick Check:
Correct syntax = row-span-2 [OK]
- Using col-span instead of row-span
- Missing dash between words and number
- Reversing order of words
<div class="grid grid-rows-4 grid-cols-2 gap-2"> <div class="row-span-2 bg-blue-500">A</div> <div class="bg-red-500">B</div> <div class="bg-green-500">C</div> <div class="bg-yellow-500">D</div> </div>
How many rows tall will the blue box labeled 'A' appear?
Solution
Step 1: Identify the row-span class on the blue box
The blue box hasrow-span-2, meaning it covers 2 rows vertically.Step 2: Understand grid rows count
The grid has 4 rows total, but the blue box only spans 2 of them.Final Answer:
2 rows tall -> Option DQuick Check:
row-span-2 means 2 rows [OK]
- Assuming it spans all rows
- Confusing rows with columns
- Ignoring the row-span class
<div class="grid grid-rows-3 grid-cols-3"> <div class="row-span3 bg-purple-400">Item</div> </div>
What is the error?
Solution
Step 1: Check the row-span class syntax
The class is written asrow-span3but Tailwind requires a dash:row-span-3.Step 2: Understand the effect of syntax error
Without the dash, Tailwind ignores the class, so no spanning happens.Final Answer:
Missing dash inrow-span3, should berow-span-3. -> Option AQuick Check:
Correct syntax needs dash [OK]
- Forgetting the dash in class names
- Assuming grid-rows count limits spanning
- Confusing row-span with col-span
Solution
Step 1: Set grid container with 3 columns and 4 rows
The container needsgrid-cols-3andgrid-rows-4to match the layout.Step 2: Make the item span 2 rows and 2 columns
Userow-span-2for vertical spanning andcol-span-2for horizontal spanning.Final Answer:
grid grid-cols-3 grid-rows-4; item: row-span-2 col-span-2 -> Option CQuick Check:
Correct grid + row-span-2 + col-span-2 [OK]
- Mixing up grid-cols and grid-rows numbers
- Using wrong span numbers for item
- Forgetting to span columns when needed
Ready to prove it?
Pass the test and this pattern moves unknown
