/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: rowspan

[this page | pdf | back links]

The HTML rowspan attribute indicates the number of rows a table cell should span. It applies to <td> and <th> elements.

 

Valid attribute values (when used with <td> and <th> elements) include:

 

Value

Description

integer

Number of rows a cell should span

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,tr,th,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
Created using HTML:<br>
<table>
<tr><th>row</th><th>val</th></tr>
<tr><td>1</td><td rowspan="2">A</td></tr>
<tr><td>2</td></tr>
</table>

<br><br>Created using JavaScript:<br>
<table>
<tr><th>row</th><th>val</th></tr>
<tr><td>1</td><td id="x1">A</td></tr>
<tr><td>2</td></tr>
</table>

<script>
var att = document.createAttribute("rowspan");
att.value = "2";
document.getElementById("x1").setAttributeNode(att);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile