What is the purpose of the “rowspan” attribute of the “td” element?
时间: 2023-11-14 13:06:33 浏览: 99
The "rowspan" attribute of the "td" element in HTML is used to specify the number of rows that a cell should span. This attribute is useful when you want to merge two or more adjacent cells in a table into a single cell that spans multiple rows.
For example, if you have a table with three rows and three columns, and you want to merge the cells in the first column of the first two rows into a single cell, you can use the "rowspan" attribute. You would set the "rowspan" attribute of the first cell to "2", indicating that it should span two rows. This would cause the first two rows of the table to appear as if they have only two cells in the first column, instead of three.
Here is an example of how to use the "rowspan" attribute:
```
<table>
<tr>
<td rowspan="2">This cell spans two rows</td>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
<td>Cell 5</td>
<td>Cell 6</td>
<td>Cell 7</td>
</tr>
</table>
```
In this example, the first cell spans two rows, so the first two rows of the table appear to have only two cells in the first column.
阅读全文