rowspan
The rowspan attribute in HTML allows a table cell (<td> or <th>) to extend across several rows, vertically merging them for improved data presentation.
rowspan attribute
The rowspan attribute in HTML allows a table cell (<td> or <th>) to extend vertically across multiple rows, effectively merging them. This helps organize table data for better visual clarity and alignment with the information's logical structure.
Syntax
index.html
<td rowspan="number">
Example
| Product | Category | Price |
|---|---|---|
| T-Shirt | Clothing | |
| Coffee Mug | Drinkware | $5.99 |
index.html
<table border="1">
<tr>
<th>Product</th>
<th rowspan="2">Category</th> <th>Price</th>
</tr>
<tr>
<td>T-Shirt</td>
<td>Clothing</td>
</tr>
<tr>
<td>Coffee Mug</td>
<td>Drinkware</td>
<td>$5.99</td>
</tr>
</table>
Definition and Usage
The rowspan attribute defines how many rows a table cell should span.
Values
- number
- The number of
rowsthat a table cell will cover or span.
- The number of
Applies To
The rowspan attribute can be used on the following HTML element:
Conclusion
The rowspan attribute in HTML helps merge table cells vertically across multiple rows for improved organization. It is used with <td> and <th> elements to span the desired number of rows. This enhances table readability and data structure clarity.