Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #610

rowspan

The rowspan attribute makes a table cell stretch down across multiple rows — used when one value genuinely applies to more than one row.

Syntax

<td rowspan="2">spans two rows</td>

Basic Example

<table>
    <tr>
        <th>Day</th>
        <th>Session</th>
    </tr>
    <tr>
        <td rowspan="2">Monday</td>
        <td>Morning: HTML</td>
    </tr>
    <tr>
        <td>Evening: CSS</td>
    </tr>
</table>

Browser output: "Monday" appears once, vertically centered, spanning both the morning and evening rows beside it — instead of being repeated on each row.

How It Works

rowspan="2" tells the browser this cell occupies its column's space across the current row and the next one — meaning the following row needs one fewer cell in that column position, since it's already covered by the spanned cell above.

Important Attributes

AttributePurpose
rowspan="n"Number of rows this cell should span, as a plain integer

Real-World Example

<tr>
    <td rowspan="3">Full Stack Batch A</td>
    <td>HTML & CSS</td>
</tr>
<tr>
    <td>JavaScript</td>
</tr>
<tr>
    <td>React</td>
</tr>

A batch schedule where the batch name genuinely applies across all three topic rows — avoiding repetitive, cluttered re-typing of "Full Stack Batch A" three separate times.

Comparison: colspan vs rowspan

colspanrowspan
DirectionStretches sideways, across columnsStretches downward, across rows
Use when...One label applies across several columns in the same rowOne value applies across several rows in the same column

Common Mistakes

  • Forgetting that a spanned cell removes the need for a corresponding cell in the rows below it — leaving that extra cell in creates a misaligned table
  • Combining colspan and rowspan in complex tables without carefully tracking the resulting grid, producing hard-to-debug alignment issues

Best Practices

  • Sketch out the intended grid on paper first for any table using multiple spans — it's easy to miscount
  • Use rowspan only when a value genuinely repeats across consecutive rows in the real data

Accessibility Considerations

Screen readers handle spanned cells correctly when the markup is valid, but as with colspan, keep spanning patterns as simple as the underlying data genuinely requires.

SEO Considerations

No direct ranking effect.

Browser & Modern HTML Notes

Well-supported and unchanged across HTML versions.

Mini Practice

  1. Build a 3-row schedule table where one cell spans all 3 rows using rowspan="3".
  2. Combine colspan and rowspan in one small table (a title row spanning all columns, plus one cell spanning two rows below it).

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →