After delving into this issue, it became apparent that the problem description and the construction of the <td rowspan="3">
in the example were causing confusion for everyone, myself included...
The solution, after hours of frustration, turned out to be quite simple:
the OP is attempting to fit 6 rows of text into a space meant for only 3 rows due to the presence of 5 <br>
tags. The content exceeds the available space, which causes the cell to overflow. Instead of setting the rowspan to 3
, it should actually be set to 6
!
Once the spacing issue was identified, one possible solution involved adding more table rows to accommodate the 6 rows of text and implementing a scrollbar when needed, while also clipping the overflowing cell when there are less than 6 rows in the table.
On the page table: The Table element: Displaying large tables in small spaces, MDN defines a table as
table { display: block; overflow: auto }
and introduces
tbody { white-space: nowrap }
to enable scrolling of table content.
I provided some commented code demonstrating the original and solution 1 with easy toggles for the class .hide
and additional rows.
Do I find this ideal? Not at all, but this seems to be how the workings of the table operate. It's not necessarily a bug, just something that requires a workaround...
UPDATE
In response to @MaxiGui's valid point below about me neglecting the OP's question on "What should I change in the CSS to get all the lines of "Text" of the rowspan cell displayed instead of being truncated", I included another solution.
The added solution 2 showcases the OP's original code, but simply switches the class .hide
between display: none
/table-row
rather than using visibility: collapse
/visible
.
When all size properties of an element have to be set to 0
(zero) to mimic display: none
, it is much simpler to use the display
property instead of visibility
to hide a table row.
It's worth noting that the OP didn't explicitly mention the need to retain visibility
...
.