Professional Documents
Culture Documents
1. Colspan:
- The colspan attribute specifies the number of columns a cell should
span horizontally.
- It is used to merge multiple adjacent cells into a single cell across
columns.
- The value of colspan is an integer that indicates how many columns the
cell should span.
- Example:
<table border="1">
<tr>
<td>Cell 1</td>
<td colspan="2">Cell 2 and Cell 3 merged</td>
<td>Cell 4</td>
</tr>
</table>
2. Rowspan:
- The rowspan attribute specifies the number of rows a cell should span
vertically.
- It is used to merge multiple cells into a single cell spanning rows.
- The value of rowspan is an integer that indicates how many rows the
cell should span.
- Example:
<table border="1">
<tr>
<td>Cell 1</td>
<td rowspan="2">Cell 2 and Cell 4 merged</td>
<td>Cell 3</td>
</tr>
<tr>
<td>Cell 5</td>
<td>Cell 6</td>
</tr>
</table>
In the above examples, the first example demonstrates the use of colspan
to merge two cells into one across columns, while the second example
shows the use of rowspan to merge two cells into one spanning rows.
Both colspan and rowspan are useful for creating complex table layouts
in HTML.