Skip to main content

Posts

Showing posts with the label Rowspan expannds a cell to many rows

Use Of Colspan and Rowspan in Tables HTML

Colspan and Rowspan are two important attributes of TD and TH tags used in HTML tables. Colspan Colspan is an attribute of TD or TH tags used to make data cells and header cells in an HTML table. We can use Colspan to expand / span a cell on many columns. For example, in the following table, the first header cell spans two columns, so here we use <th colspan="2">Marks</th> to get the required result in the displayed html table. Marks Maths Computer 100 87 The complete HTML coding is as follows: <table border="1"> <tr> <th colspan="2">Marks</th> </tr> <tr> <th>Maths</th><th>Computer</th></tr> <tr> <td>100</td><td>87</td> </tr> </table> Rowspan Rowspan attribute is used to expand or span a cell to multiple rows. For example, in the following table example, the first TH cell (Marks) spans on two rows. We use <th row