Content · Web Development · HTML

HTML colspan and rowspan Attributes: Spanning Cells

Colspan lets a cell cover several columns; rowspan lets it cover several rows. These attributes change the shape of the table grid.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Colspan lets a cell cover several columns; rowspan lets it cover several rows. These attributes change the shape of the table grid. Before writing the code, picture the information as a small grid. Each label should help a reader understand the value next to it.

What You Need to Know


Count occupied grid positions carefully so rows line up logically. A merged cell can make accessibility harder when headers become ambiguous.

Read a table like a story about data. The caption says what you are looking at; row and column headers explain what the numbers or words mean.

Example: See It in Action


This example keeps the idea small. Copy it carefully, then follow the explanation instead of guessing what the browser will do.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<table>
    <tr>
        <th scope="col">Name</th>
        <th scope="col">Monday</th>
        <th scope="col">Tuesday</th>
    </tr>
    <tr>
        <th scope="row">Alex</th>
        <td colspan="2">Away</td>
    </tr>
    <tr>
        <th scope="row" rowspan="2">Maya</th>
        <td>Robotics</td>
        <td>Music</td>
    </tr>
    <tr>
        <td>Sports</td>
        <td>Art</td>
    </tr>
</table>

Let’s Understand the Example


  • Table represents information whose row and column relationships matter.
  • Th is a header cell. Its text explains what nearby data cells mean.
  • Colspan makes a table cell stretch across several columns.
  • Rowspan makes a table cell stretch across several rows.
  • Scope explains which table row, column or group a th cell labels.

Look at a data cell and ask: “What row and column does this value belong to?” The header elements help answer that question, including for people who navigate the table with a screen reader.

What Should You See?


You should see a grid for the data table, with headers such as “Name”, “Monday”, “Tuesday”. The browser displays cells, but meaningful table markup also helps readers connect each cell to its labels.

Read the first data row aloud together with its column labels. If you cannot explain a value without pointing to its position on screen, strengthen the headers.

Try It Yourself


  1. Sketch the occupied columns for each example row on paper.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Using rowspan or colspan as decoration while creating a broken grid.
  • Do not replace actual header cells with bold ordinary cells. Header markup is part of the meaning, not just the appearance.

Key Takeaways


  • Colspan lets a cell cover several columns; rowspan lets it cover several rows.
  • Table represents information whose row and column relationships matter.
  • Count occupied grid positions carefully so rows line up logically. A merged cell can make accessibility harder when headers become ambiguous.
Share this resourceSend this page to someone who may find it useful.