Easy Tutorial
❮ Prop Win Innerheight Prop Img Border ❯

Table cellSpacing Attribute


Definition and Usage

The cellSpacing attribute sets or returns the amount of space between cells in a table (in pixels).

Syntax

Setting the cellSpacing attribute:

Returning the cellSpacing attribute:

Note: The cellSpacing attribute has no default value.

Value Description
number Sets the space between cells in pixels
percent Sets the space between cells as a percentage

Browser Support

All major browsers support the cellSpacing attribute.


Example

Change the space between table cells and the space between the cell edges and their content:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function padding(){
    document.getElementById('myTable').cellPadding="25";
}
function spacing(){
    document.getElementById('myTable').cellSpacing="15";
}
</script>
</head>
<body>

<table id="myTable" border="1">
<tr>
        <td>cell 1</td>
        <td>cell 2</td>
</tr>
<tr>
        <td>cell 3</td>
        <td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="padding()">Modify Cell Padding</button>
<button type="button" onclick="spacing()">Modify Cell Spacing</button>

</body>
</html>

❮ Prop Win Innerheight Prop Img Border ❯