0Pricing
HTML Academy · Lesson

colspan and rowspan for Spanning

Merge cells across columns and rows.

What Is Cell Spanning?

By default, each table cell occupies one row and one column. Spanning allows a cell to stretch across multiple columns or rows:

  • colspan — span multiple columns
  • rowspan — span multiple rows

colspan

The colspan attribute makes a cell span multiple columns:

<table>
  <tr>
    <th colspan="3">2024 Quarterly Sales</th>
  </tr>
  <tr>
    <th>Q1</th>
    <th>Q2</th>
    <th>Q3</th>
  </tr>
  <tr>
    <td>$10k</td>
    <td>$12k</td>
    <td>$15k</td>
  </tr>
</table>

All lessons in this course

  1. table tr td and th
  2. thead tbody tfoot Structure
  3. colspan and rowspan for Spanning
  4. Table Accessibility scope summary caption
← Back to HTML Academy