td/th rowSpanProperty
td/th Object
Definition and Usage
The rowSpan property can set or return the number of rows a cell spans.
Syntax
Set the rowSpan property:
tdObject.rowSpan="number"
or
thObject.rowSpan="number"
or
thObject.rowSpan="number"
Return the rowSpan property:
tdObject.rowSpan
or
thObject.rowSpan
or
thObject.rowSpan
Tip:The rowSpan property has no default value.
| Value | Description |
|---|---|
| number | Defines the number of rows a cell spans |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the rowSpan property
Examples
Examples
The following example changes the number of rows a cell spans:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function displayResult(){
document.getElementById("myHeader1").rowSpan="2";
}
</script>
</head>
<body>
<table border="1">
<tr>
<th id="myHeader1">Month</th>
<th id="myHeader2">Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100.00</td>
</tr>
<tr>
<td>February</td>
<td>$10.00</td>
</tr>
<tr>
<td>March</td>
<td>$80.00</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Modify the number of rows spanned by the first cell</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function displayResult(){
document.getElementById("myHeader1").rowSpan="2";
}
</script>
</head>
<body>
<table border="1">
<tr>
<th id="myHeader1">Month</th>
<th id="myHeader2">Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100.00</td>
</tr>
<tr>
<td>February</td>
<td>$10.00</td>
</tr>
<tr>
<td>March</td>
<td>$80.00</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Modify the number of rows spanned by the first cell</button>
</body>
</html>
Try it Yourself »
td/th Object Other Extensions