---
title: "What is Table Colspan and Rowspan in HTML?"  
description: "Using colspan and rowspan attributes allows for more complex table layouts and designs."  
author: "Ashutosh Patel"  
published: 2024-06-05  
updated: 2024-06-05  
canonical: https://www.mindstick.com/articles/336019/what-is-table-colspan-and-rowspan-in-html  
category: "html"  
tags: ["html", "html5", "html table"]  
reading_time: 2 minutes  

---

# What is Table Colspan and Rowspan in HTML?

### HTML Table colspan and rowspan

In HTML [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development), `colspan` and `rowspan` are [attributes](https://www.mindstick.com/interview/34453/what-are-attributes-in-dot-net) used to span a cell across [multiple columns](https://www.mindstick.com/forum/156805/how-to-set-primary-key-constraints-on-multiple-columns-in-a-table-in-sql-server) or rows, respectively.

#### Table Colspan

- colspan is an [attribute](https://www.mindstick.com/interview/1137/what-is-attributes-and-reflection-in-c-sharp) used to specify the number of columns that a cell should span horizontally.
- It allows a single cell to occupy [space](https://answers.mindstick.com/qa/52139/name-of-the-moon-mission-2024-which-was-unveiled-by-national-aeronautics-and-space-administration) across multiple adjacent columns within a table row.
- The value of colspan indicates the number of columns that the cell should span.

## Example-

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Table colspan</title>
</head>
<body>
    <table border="1">
        <tr>
          <td>Cell 1</td>
          <td colspan="2">Spanned Cell</td>
          <td>Cell 4</td>
        </tr>
    </table>
</body>
</html>
```

## [Output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular)-

| Cell 1 | Spanned Cell | Cell 4 |
| --- | --- | --- |

#### \
Table Rowspan

- rowspan is an attribute used to specify the number of rows that a cell should span vertically.
- It allows a single cell to occupy space across multiple adjacent rows within a table column.
- The value of rowspan indicates the number of rows that the cell should span.

## Example-

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Table rowspan</title>
</head>
<body>
    <table border="1">
        <tr>
          <td rowspan="2">Spanned Cell</td>
          <td>Cell 2</td>
          <td>Cell 3</td>
        </tr>
        <tr>
          <td>Cell 5</td>
          <td>Cell 6</td>
        </tr>
    </table>
</body>
</html>
```

## Output-

| Spanned Cell | Cell 2 | Cell 3 |
| --- | --- | --- |
| Cell 5 | Cell 6 |  |

Using `colspan` and `rowspan` attributes allows for more [complex](https://yourviews.mindstick.com/view/81861/how-will-construction-of-new-parliament-complex-take-place) table layouts and designs, where cells can span across [multiple rows](https://www.mindstick.com/forum/12845/how-to-responsive-div-table-struggle-multiple-rows) or columns, providing flexibility in [organizing](https://www.mindstick.com/articles/310791/all-you-need-to-know-about-organizing-before-moving) and presenting tabular data.

---

Original Source: https://www.mindstick.com/articles/336019/what-is-table-colspan-and-rowspan-in-html

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
