If you're confused how table layouts work, they basically start at x=0, y=0 and work their way across. Let's explain with graphics, because they're so much fun!

When you start a table, you make a grid. Your first row and cell will be in the top left corner. Think of it like an array pointer, moving to the right with each incremented value of x, and moving down with each incremented value of y.

For your first row, you're only defining two cells. One spans 2 rows down and one spans 4 columns across. So when you reach the end of your first row, it looks something like this:

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
</table>

Now that the row has ended, the "array pointer" jumps down to the next row. Since x position 0 is already taken up by a previous cell, x jumps to position 1 to start filling in cells. * See note about difference between rowspans.

This row has four cells in it which are all 1x1 blocks, filling in the same width of the row above it.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

The next row is all 1x1 cells. But, for example, what if you added an extra cell? Well, it would just pop off the edge to the right.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

* But what if we instead (rather than adding the extra cell) made all these cells have a rowspan of 2? The thing you need to consider here is that even though you're not going to be adding any more cells in the next row, the row still must exist (even though it's an empty row). If you did try to add new cells in the row immediately after, you'd notice that it would start adding them to the end of the bottom row.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
    </tr>
    <tr>
        <td></td>
    </tr>
</table>

Enjoy the wonderful world of creating tables!

Answer from animuson on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ att_colspan.asp
HTML colspan Attribute
The colspan attribute defines the number of columns a table cell should span.
๐ŸŒ
W3Schools
w3schools.com โ€บ html โ€บ html_table_colspan_rowspan.asp
HTML Table Colspan & Rowspan
HTML tables can have cells that span over multiple rows and/or columns. To make a cell span over multiple columns, use the colspan attribute:
Discussions

How to do colspan for more than 1000 columns in a HTML table? - Stack Overflow
I have a table with 1440 columns in 1 row and 1 columns in another row. I am able to do colspan up to 1000 columns. How can I make it working for 1440 columns, If not possible is there any alternat... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to build this table using html only (rowspan and colspan)?
I tried this example, but the thought process given at that example after the first row part didnโ€™t work here. So, I was wondering how to solve this problem? Iโ€™ve tried this code: More on forum.freecodecamp.org
๐ŸŒ forum.freecodecamp.org
0
November 3, 2022
How do you use colspan and rowspan in HTML tables? - Stack Overflow
I don't know how to merge rows and columns inside HTML tables. Can you please help me with making such a table in HTML? More on stackoverflow.com
๐ŸŒ stackoverflow.com
HTML: how to use colspan and rowspan? - Stack Overflow
I am trying to build a very simple array, but somehow It is not working How I think it should. Here is an example: table, th, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ HTMLTableCellElement โ€บ colSpan
HTMLTableCellElement: colSpan property - Web APIs | MDN
September 4, 2025 - The colSpan property of the HTMLTableCellElement interface represents the number of columns this cell must span; this lets the cell occupy space across multiple columns of the table. It reflects the colspan attribute.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ html-colspan-attribute
HTML colspan Attribute - GeeksforGeeks
August 21, 2025 - The colspan attribute in HTML specifies the number of columns a cell should span. It allows the single table cell to span the width of more than one cell or column.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 70923717 โ€บ how-to-do-colspan-for-more-than-1000-columns-in-a-html-table
How to do colspan for more than 1000 columns in a HTML table? - Stack Overflow
Two [Colspan] must have a line between them . 2022-01-31T09:49:15.67Z+00:00 ... @dorianDevTech Multiple cells can't use. I have a slider inside the first row cell. that should move to 1440 cell. now its moving up to 1000 cell only. 2022-01-31T10:56:29.693Z+00:00 ... Save this answer. Show activity on this post. As already stated you should use div(s) instead of table : Just consider <div class = "table-data"></div> as td tag . ... <!DOCTYPE html> <html> <head> <style> #colspan{ border: 3px solid black; padding: 7px; margin-bottom: 10px; } .table-data{ border: 3px solid black; padding: 10px; display: inline; } .table{ display: table; } </style> </head> <body> <div class = "table"> <div id = "colspan"></div> <div> <div class = "table-data"></div> <div class = "table-data"></div> <div class = "table-data"></div> <div class = "table-data"></div> ....
๐ŸŒ
freeCodeCamp
forum.freecodecamp.org โ€บ html-css
How to build this table using html only (rowspan and colspan)? - HTML-CSS - The freeCodeCamp Forum
I tried this example, but the thought process given at that example after the first row part didnโ€™t work here. So, I was wondering how to solve this problem? Iโ€™ve tried this code: <table border="1"> <tโ€ฆ
Published ย  November 3, 2022
Find elsewhere
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ colspan-in-html
What Is Colspan in HTML?- Scaler Topics
May 4, 2023 - Colspan in HTML is an attribute that defines the number of columns a single cell can span in a table. The colspan attribute allows single table cells to occupy the width of one or more than one column or cells.
Top answer
1 of 12
124

If you're confused how table layouts work, they basically start at x=0, y=0 and work their way across. Let's explain with graphics, because they're so much fun!

When you start a table, you make a grid. Your first row and cell will be in the top left corner. Think of it like an array pointer, moving to the right with each incremented value of x, and moving down with each incremented value of y.

For your first row, you're only defining two cells. One spans 2 rows down and one spans 4 columns across. So when you reach the end of your first row, it looks something like this:

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
</table>

Now that the row has ended, the "array pointer" jumps down to the next row. Since x position 0 is already taken up by a previous cell, x jumps to position 1 to start filling in cells. * See note about difference between rowspans.

This row has four cells in it which are all 1x1 blocks, filling in the same width of the row above it.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

The next row is all 1x1 cells. But, for example, what if you added an extra cell? Well, it would just pop off the edge to the right.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

* But what if we instead (rather than adding the extra cell) made all these cells have a rowspan of 2? The thing you need to consider here is that even though you're not going to be adding any more cells in the next row, the row still must exist (even though it's an empty row). If you did try to add new cells in the row immediately after, you'd notice that it would start adding them to the end of the bottom row.

<table>
    <tr>
        <td rowspan="2"></td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
        <td rowspan="2"></td>
    </tr>
    <tr>
        <td></td>
    </tr>
</table>

Enjoy the wonderful world of creating tables!

2 of 12
113

I'd suggest:

table {
    empty-cells: show;
    border: 1px solid #000;
}

table td,
table th {
    min-width: 2em;
    min-height: 2em;
    border: 1px solid #000;
}
<table>
    <thead>
        <tr>
            <th rowspan="2"></th>
            <th colspan="4">&nbsp;</th>
        </tr>
        <tr>
            <th>I</th>
            <th>II</th>
            <th>III</th>
            <th>IIII</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td>1</td>
            <td>2</td>
            <td>3</td>
            <td>4</td>
         </tr>
    </tbody>
</table>

References:

  • td element.
  • th element.
  • tbody element.
  • thead element.
  • table element.
๐ŸŒ
HTML Tables
htmltables.io โ€บ attributes โ€บ colspan
HTML <colspan> Attribute โ€” HTML Tables
April 14, 2024 - Colspan is an HTML attribute, specifically used for HTML tables, that allows you to make a row or column span across multiple <td> or <th> cells. In a standard table, each cell would be associated with one row or column.
๐ŸŒ
BFO
bfo.com โ€บ products โ€บ report โ€บ docs โ€บ tags โ€บ atts โ€บ colspan.html
colspan
The colspan attribute can be set to cause a single table cell to span more than one column. It's use is identical to HTML.
๐ŸŒ
SitePoint
sitepoint.com โ€บ html hub โ€บ table colspan & rowspan
HTML Table Colspan & Rowspan | SitePoint โ€” SitePoint
HTML tables display data in rows and columns. To make tables clearer, it's possible to merge cells. The colspan attribute merges cells horizontally, while the rowspan attribute merges them vertically.
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ att_td_colspan.asp
HTML td colspan Attribute
The colspan attribute defines the number of columns a cell should span. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected] ยท If you want to report an error, or ...
๐ŸŒ
W3Schools
w3schools.com โ€บ html โ€บ html_table_headers.asp
HTML Table Headers
You will learn more about colspan and rowspan in the Table colspan & rowspan chapter.
Top answer
1 of 2
3

The table will have 8 columns, but you have effectively reduced it to 2. The table rendering algorithm will make things as efficient as it can.

By adding an additional row you can see what is happening

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>
</head>
<body>

<table width=100%>
  <tr>
    <th colspan="8">Monthly Savings</th>
  </tr>
  <tr >
    <td colspan="2">January</td>
    <td rowspan="3" colspan="6" >$30000</td>
  </tr>
  <tr>
    <td colspan="2">February</td>
  </tr>
    <tr>
    <td colspan="2">March</td>
  </tr>
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    <td>8</td>
  </tr>
</table>

</body>
</html>

What you are better off doing is assigning width to the columns

table, th, td {
    border: 1px solid black;
}
<table width=100%>
  <tr>
    <th colspan="2">Monthly Savings</th>
  </tr>
  <tr >
    <td style="width:33%">January</td>
    <td rowspan="3" style="width:66%" >$30000</td>
  </tr>
  <tr>
    <td>February</td>
  </tr>
    <tr>
    <td>March</td>
  </tr>
</table>
2 of 2
1

because the you add heading in single <th> so make id different

<th colspan="2">Monthly</th>
<th colspan="6">Savings</th>

so it will display 2 for month and 6 for saving

<!DOCTYPE html>
<html>

<head>
  <style>
    table,
    th,
    td {
      border: 1px solid black;
    }
  </style>
</head>

<body>

  <table width=100%>
    <tr>
      <th colspan="2">Monthly</th>
      <th colspan="6">Savings</th>
    </tr>
    <tr>
      <td colspan="2">January</td>
      <td rowspan="3" colspan="6">$30000</td>
    </tr>
    <tr>
      <td colspan="2">February</td>
    </tr>
    <tr>
      <td colspan="2">March</td>
    </tr>
  </table>

</body>

</html>
๐ŸŒ
HubSpot
blog.hubspot.com โ€บ website โ€บ what-is-colspan-in-html
What Is colspan in HTML?
February 11, 2025 - Colspan is an HTML attribute that allows you to span a row or column across multiple cells. This means that instead of having multiple columns, the cells will merge and the content will span multiple columns.
๐ŸŒ
W3Schools
w3schools.com โ€บ HTML โ€บ tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
Medium
medium.com โ€บ @brajagopal.tripathi โ€บ what-does-colspan-mean-in-html-af9c42784baf
What does Colspan mean in HTML?. The Colspan attribute in HTML specifiesโ€ฆ | by Brajagopal Tripathi | Medium
November 9, 2023 - The Colspan attribute in HTML specifies the number of columns a cell should span. This means that a single table cell can take up the width of multiple columns, effectively merging them into one larger cell.
๐ŸŒ
Createafreewebsite
createafreewebsite.net โ€บ colspan.htm
Colspan HTML5 Tables
In Figure #1 shown below we have ... <td></td> <td></td> <td></td> </tr> colspan is an attribute of the <td> tag. It tells the browser how many columns one cell of a row should span....
๐ŸŒ
The Webmaster
thewebmaster.com โ€บ html โ€บ attributes โ€บ colspan
HTML colspan Attribute
The colspan attribute specifies the number of columns in a <table> element the <td> cell extends.