Or should the total amount of cells equal to columns * rows
?
A table with different amount of cells on different rows seems to pass the W3 Validator.
Spanning Multiple Rows and Columns Spanning allow you to extend table rows and columns across multiple other rows and columns. Normally, a table cell cannot pass over into the space below or above another table cell. But, you can use the rowspan or colspan attributes to span multiple rows or columns in a table.
The Solution: Select the first part of the text to which you want to apply a different number of columns, choose Format » Columns, specify the number of columns, make sure that "Selected text" rather than "Whole document" is selected in the "Apply to" drop-down list, and click the OK button.
That does not violate the definition. But you should use the colspan attribute to expand the column to the whole row:
<table>
<tr>
<td>Row with</td>
<td>2 cols</td>
</tr>
<tr>
<td colspan="2">Row with only one col</td>
</tr>
</table>
That will also help if you have borders around the cells.
You can even have tables with a column that expands to two rows:
<table>
<tr>
<td rowspan="2">First column in row 1 and row 2</td>
<td>Second column in row 1</td>
</tr>
<tr>
<td>second column in row 2</td>
</tr>
</table>
You can use colspan
, but the sum including the colspan
value(s) should be equal for the table to render properly.
<table>
<tr>
<td colspan="2">blah</td>
</tr>
<tr>
<td>blah</td>
<td>boo</td>
</tr>
</table>
The first row has one cell but it spans 2 cells because of the colspan
, the second row has two cells and this is perfectly valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With