HTML Standard attribute: colspan
[this page | pdf | back links]
The HTML colspan attribute indicates the number
of columns a table cell should span. It applies to <td> and <th> elements.
A value of zero, i.e.
using colspan="0", in theory has a special meaning, namely that the
cell should be spanned to the last column of the column group, but this is not
recognised by some browsers.
Valid attribute
values (when used with <td>
and <th>
element) include:
Value
|
Description
|
integer
|
Number of columns a
cell should span
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td,th,tr,caption {border: thin solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr><td>col 1</td><td>col 2</td></tr>
<tr><td colspan="2">merged cell (HTML)</td></tr>
<tr><td id="element">merged cell (JavaScript)</td></tr>
</table>
<script>
document.getElementById("element").colSpan = "2";
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes