Reputation: 21947
I have a table with three rows and three columns. How can I combine the last row columns? My HTML content:
<table>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td>Here I need a cell by all width</td></tr>
</table>
Upvotes: 17
Views: 58385
Reputation: 44386
For this exact purpose the colspan
attribute was created.
<table>
<tr><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td></tr>
<tr><td colspan="3">Here I need a cell by all width</td></tr>
</table>
Similarly you can use use the rowspan
attribute if you want to span multiple rows.
<table>
<tr><td></td><td></td><td rowspan="3">Spans full table height</td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
</table>
To learn more about these two attributes visit the official documentation on w3.org.
Also I urge you not to use tables unless you need to present tabular data.
Upvotes: 8