FileGizmo glossary
Colspan and rowspan
Colspan and rowspan let a single table cell occupy more than one position in the grid. A cell with colspan of three fills three columns; one with rowspan of two also fills the same column in the row below. They are how merged cells are written in HTML.
An HTML table is a grid, and the cells in it do not have to be one square each. Two attributes say otherwise.
colspan makes a cell cover several columns. It is how a heading sits above the three columns it describes. rowspan makes a cell cover several rows in the same column, which is how a category label sits beside the four items in it. Both take a number, and both default to one.
The grid is not the markup
The important consequence is that a row’s markup and a row’s width are different things.
A row containing three cell tags might occupy four grid positions, if one of those tags spans two columns. It might occupy five, if a cell in the row above declared a rowspan that reaches down into this one. Nothing in this row’s own markup says so.
That is why reading a table correctly means walking a grid and tracking what earlier rows are still occupying, rather than mapping over the cell tags. It is more work than it looks, and it is the part most quick converters skip.
What goes wrong when they are ignored
A converter that maps cell tags to fields produces the right answer for a table with no spans and a quietly wrong one for a table with any.
Every value after a span lands one column to the left of where it belongs. The file is well formed, opens without complaint, and no longer lines up with its own headers. Because it is only misaligned from the first merged cell onwards, the top of the file often looks correct, which is the worst possible failure mode: it passes a glance.
Expanding the span instead, so the value repeats in each position it covers, keeps the alignment. The repetition may not be what the original meant, but it is visible, and the reader can decide.
Frequently asked questions
Why do spans break a conversion to CSV?
CSV has no merged cell. Every row has the same number of fields, so a converter has to either expand the span or ignore it, and ignoring it shifts every following value one column to the left of where it belongs.
What should a converter do with them?
Repeat the value across each position the cell covers. That preserves the alignment between values and headers, which is the thing a reader will check, and the repetition is visible rather than silent.
Do spans affect the number of columns in a row?
They affect the number of grid positions, not the number of cell tags. A row of three tags where one spans two columns occupies four positions, which is why counting tags gives the wrong width.