🌐
W3Schools
w3schools.com β€Ί html β€Ί html_table_colspan_rowspan.asp
HTML Table Colspan & Rowspan
<table> <tr> <th colspan="2">Name</th> ... colspan attribute represents the number of columns to span. To make a cell span over multiple rows, use the rowspan attribute:...
🌐
Table Tag Generator
tabletag.net
Table Tag Generator | rowspan? colspan? You don't need to worry about them!
Table Tag Generator is a GUI tool to merge multiple cells intuitively as seen at. rowspan? colspan? You don't need to worry anymore. You can get complex tables without breaking layout.
Discussions

URGENT : Please how can i do this with table rowspan and colspan
I've started to prefer using CSS grid, is that an option? You can either define named grid template areas that match your areas, or you could can define a 4 x 5 grid and for each of your sub-items specify where they fall in the grid. More on reddit.com
🌐 r/html5
21
7
June 21, 2024
How to build this table using only rowspan and colspan in html?
Straight to jail! More on reddit.com
🌐 r/webdev
345
912
November 3, 2022
java - Generating html table from 2d array with colspan and rowspan - Stack Overflow
I need to generate html table from 2d array containing only data, colspan and rowspan. I have no need for margins, heights and widths. Only td and tr. I know table cell width and height, result is ... More on stackoverflow.com
🌐 stackoverflow.com
I got tired of manually coding complex HTML tables, so I built a free visual generator with advanced features.
This is awesome. Thanks. More on reddit.com
🌐 r/webdev
13
37
July 25, 2025
🌐
Htmlcodegenerator-tools
htmlcodegenerator-tools.com β€Ί 2020 β€Ί 01 β€Ί html-css-simple-responsive-html-table-generator-colspan-rowspan.html
Responsive HTML Table Generator with Colspan and Rowspan
January 6, 2020 - Powerful online tool to generate Simple and Responsive HTML table with colspan and rowspan cell merge and cell split without programming knowledge. You can use generated html table code in your website or blog
🌐
HTMLTables
htmltables.io β€Ί home
HTML Table Generator β€” Build and Style Tables
While our generator provides a range of styles, keep in mind that the possibilities are not limited to what we offer. The code output empowers you to effortlessly customize and refine styles, allowing you to achieve the ideal table for your website. In the near future, we plan to add even more features (like colspan and rowspan, to name a few).
🌐
Johnpatel
johnpatel.com β€Ί html-table-generator
HTML Table Generator & Builder | HTML Table Tags & Attributes
HTML Table Generator & Builder, HTML Table Tags & Attributes. Merge Table with Rowspan and Colspan
🌐
Html Quiz Generator
quizgenerator.3schools.in β€Ί tablegenerator β€Ί webtools
Advanced HTML table generator with Colspan and Rowspan - Html Quiz Generator
October 1, 2022 - Html table generator provides rowspan and colspan. By using this feature, you can easily marge a cell according to your needs and also add new cell where you want want, delete any cell by using this advanced html table generator.
🌐
SitePoint
sitepoint.com β€Ί html hub β€Ί table colspan & rowspan
HTML Table Colspan & Rowspan | SitePoint β€” SitePoint
Combine both colspan and rowspan for complex table structures. Follow best practices to keep table code accessible and easy to maintain. Choose tables for data display and use CSS for page layout. ... The colspan attribute makes one cell span several columns. Use this code: ... <table border="1"> <tr> <th>Item</th> <th colspan="2">Details</th> </tr> <tr> <td>T-Shirt</td> <td>Size</td> <td>Color</td> </tr> </table>
🌐
GitHub
github.com β€Ί donquixote β€Ί cellbrush
GitHub - donquixote/cellbrush: HTML tables with support for rowspan and colspan, with string keys for rows and columns, generated with PHP.
A library to generate complex HTML tables with PHP, with support for rowspan and colspan.
Starred by 48 users
Forked by 12 users
Languages Β  PHP 100.0% | PHP 100.0%
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί html β€Ί html-table-colspan-and-rowspan
HTML Table Colspan and Rowspan - GeeksforGeeks
December 1, 2025 - Widely used in complex tables, about 80–90% rely on them for better layout and readability. HTML Table with colspan allows you to merge or combine adjacent table cells horizontally, creating a single, wider cell that spans across multiple columns.
🌐
W3Schools
w3schools.com β€Ί tags β€Ί tryit.asp
Colspan and rowspan
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
Pustudy
pustudy.com β€Ί calculators β€Ί convert β€Ί color_tools β€Ί html-table-generator.html
Online HTML Table Generator - Pustudy.Com
4. Another best thing is you can undo the merge cells by the "Split" button. Just drag and drop the cells which you want to join and click split. Also, rowspan and colspan adjust itself with the right manner inside the HTML cell.
🌐
Reddit
reddit.com β€Ί r/html5 β€Ί urgent : please how can i do this with table rowspan and colspan
r/html5 on Reddit: URGENT : Please how can i do this with table rowspan and colspan
June 21, 2024 - <html> <head> <title>Turan Alizada 684.23e, 1st Question</title> <style> table { width: 800px; height: 80vh; border-collapse: collapse; margin: 100px auto; background-color: white; } td { border: 1px solid black; text-align: center; vertical-align: middle; background-color: gray; color: white; font-size: 20px; } </style> </head> <body> <table> <tr> <td rowspan="4" colspan="2">No</td> <td colspan="4">problem</td> <td rowspan="1" colspan="2">for</td> <td rowspan="1" colspan="2">a web</td> </tr> <tr> <td colspan="4" rowspan="2">professional</td> </tr> <tr> <td rowspan="6" colspan="4">as</td> <tr> <tr> <td rowspan="2" colspan="6">you</td> </tr> <tr></tr> <tr> <td rowspan="2" colspan="2">will</td> <td rowspan="4" colspan="4">see</td> </tr> <tr></tr> <tr> <td rowspan="2" colspan="2">In</td> <td colspan="2">few</td> <td colspan="2">minutes!</td> </tr> </table> </body> </html>
🌐
HTML.com
html.com β€Ί tables β€Ί rowspan-colspan
Table Rowspan And Colspan In HTML Explained (With Examples) Β»
December 3, 2019 - How to use COLSPAN and ROWSPAN so that a table cell takes up more than one column or one row.
🌐
CodeSandbox
codesandbox.io β€Ί s β€Ί rowspan-colspan-table-efgjf
rowspan-colspan-table - CodeSandbox
May 14, 2020 - rowspan-colspan-table by fantaishao
Published Β  May 14, 2020
Author Β  fantaishao
🌐
Hermetic Systems
html-table-creator-tool.soft112.com
HTML Table Creator Tool 12.00 Free Download
This program is an interactive TABLE generator which handles COLSPAN and ROWSPAN, thus enabling creation of complex tables with cells larger than 1x1. Cell specifications can include cell content, font name, font size, color, alignment, etc. A cell specification can be copied to other cells, ...
🌐
Reddit
reddit.com β€Ί r/webdev β€Ί how to build this table using only rowspan and colspan in html?
How to build this table using only rowspan and colspan in html? : r/webdev
November 3, 2022 - I found it easiest to go one attribute at a time, go through each row and see how many columns each cell need to take up (e.g. 1 needs colspan="3") Once you've got all of those in, go back through each cell and do the same for rows (e.g. 2 needs rowspan="3" Might help to visualise with the columns and rows marked out: ... I see no issue in this? Just a bit of an arse .... Lower comments are correct. ... This was a classic exercise that was submitted in 00' html interviews. You might not use this kind of knowledge a lot (but you might still find this kind of sketchy table in newsletter integration or old client websites).
Top answer
1 of 3
1

iterate your rows and columns in your 2d array and create the HTML tags using a StringBuilder.

public String toHTML(String[][] data){
    StringBuilder sb = new StringBuilder();
    sb.append("<table>\n");
    for(int row = 0; row < data.length; row++){
        sb.append("\t<tr>\n");
        for(int col = 0; col < data[0].length; col++){
            sb.append("\t\t<td>" + data[row][col] + "</td>\n");
        }
        sb.append("\t</tr>\n");
    }
    sb.append("</table>");
    return sb.toString();
}

If you use it like this:

String[][] data = {{"r0c1", "r0c2", "r0c3"},
                   {"r1c1", "r1c2", "r1c3"}};   
System.out.println(toHTML(data));

It will produce this:

<table>
    <tr>
        <td>r0c1</td>
        <td>r0c2</td>
        <td>r0c3</td>
    </tr>
    <tr>
        <td>r1c1</td>
        <td>r1c2</td>
        <td>r1c3</td>
    </tr>
</table>
2 of 3
0

You could create a container class for the cells, which manages the correct positioning of multi-column and multi-row cells.

You have a grid of slots and when you place a cell that span several columns or rows, you invalidate the slots that this big cell occupies, keeping a reference to the real cell only in the top left slot. When you print the markup, don't print invalidated cells.

You seem to create your tables top down, so a natural approach would be to keep track of the current row and columns, so that inserting a cell can find the next free one.

If you don't want to dimension the table beforehand or jiggle an ever-resizing grid of cells, you can store the cells in a hash map with their position in the grid as key, so that you can easily append cells without worrying to overflow the table.

An implementation with your example table is below. I'm not good with Java – I lack both the skills and the software – so I've writen the code in D. The principal idea should be clear, I think. D has associative arrays built in and V[K] corresponds to Java's java.util.HashMap<K, V>.

import std.stdio;
import std.array;
import std.string;

class Cell
{
public:
    this(string _label, int _colSpan, int _rowSpan)
    {
        label = _label;
        colSpan = _colSpan;
        rowSpan = _rowSpan;
    }

    string toHtml() {
        auto app = appender!string();

        app.put("        <td");
        if (colSpan > 1) app.put(format(" colspan='%d'", colSpan));
        if (rowSpan > 1) app.put(format(" rowspan='%d'", rowSpan));
        app.put(">");
        app.put(label);
        app.put("</td>\n");

        return app.data;
    } 

private:
    string label;
    int colSpan;
    int rowSpan;
}

class Table
{
public:
    this() {
    }

    void newRow() {
        row++;
        col = 0;
    }

    void add(string label, int colSpan = 1, int rowSpan = 1)
    {
        assert(row >= 0);
        assert(colSpan > 0);
        assert(rowSpan > 0);

        auto c = new Cell(label, colSpan, rowSpan);

        while (key(col, row) in cell) col++;

        for (int j = 0; j < rowSpan; j++) {
            for (int i = 0; i < colSpan; i++) {
                addCell(col + i, row + j,
                    (i == 0 && j == 0) ? c : null);
            }
        }

        col += colSpan;
    }

    string toHtml() {
        auto app = appender!string();

        app.put("<table>\n");

        for (int y = 0; y < nrow; y++) {
            app.put("    <tr>\n");

            for (int x = 0; x < ncol; x++) {

                if (key(x, y) !in cell) {
                    app.put("        <td></td>\n");
                } else {
                    Cell c = cell[key(x, y)];

                    if (c) app.put(c.toHtml());
                }
            }
            app.put("    </tr>\n");
        }
        app.put("</table>");

        return app.data;
    }

private:
    void addCell(int x, int y, Cell c) {
        Cell *p = key(x, y) in cell;

        if (x + 1 > ncol) ncol = x + 1;
        if (y + 1 > nrow) nrow = y + 1;

        assert(p is null);
        cell[key(x, y)] = c;
    }

    static uint key(uint x, uint y)
    {
        const offset = 1u << 16;
        return y * offset + x;
    }


    Cell[uint] cell;        // map of positions to cells
    int row = -1;           // current row
    int col;                // current column
    int nrow;               // number of rows
    int ncol;               // number of columns
};

void main()
{
    auto tbl = new Table();

    tbl.newRow();
    tbl.add("Total", 1, 9);
    tbl.add("Subtotal A-C", 1, 3);
    tbl.add("detail A");

    tbl.newRow();
    tbl.add("detail B");

    tbl.newRow();
    tbl.add("detail C");

    tbl.newRow();
    tbl.add("Subtotal D-F", 1, 3);
    tbl.add("detail D");

    tbl.newRow();
    tbl.add("detail E");

    tbl.newRow();
    tbl.add("detail F");

    tbl.newRow();
    tbl.add("Subtotal G-I", 1, 3);
    tbl.add("detail G");

    tbl.newRow();
    tbl.add("detail H");

    tbl.newRow();
    tbl.add("detail I");

    writeln(tbl.toHtml());   
}
🌐
Htmltable
htmltable.com β€Ί rowspan
Merge HTML Table Cells Vertically with Rowspan
Most visual HTML table generators don't support setting the rowspan easily. Usually you need to create the code for a plain XΓ—Y table, then using some WYSIWYG HTML editor, you have to manually add the rowspan attribute, and remove the unwanted ...
🌐
Tech Edu Byte
techedubyte.com β€Ί home β€Ί html table generator
HTML Table Generator - Tech Edu Byte
January 18, 2025 - β€’ Saves Time: Quickly generate tables without writing code manually. β€’ Beginner-Friendly: No need to memorize complex HTML syntax. β€’ Customizable: Tools with CSS options let you create professional-looking tables effortlessly. β€’ Colspan and Rowspan Support: Easily create complex table structures.