Table cellSpacingProperty

Table 对象参考手册Table Object

Definition and Usage

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

Syntax

Set the cellSpacing property:

tableObject.cellSpacing="number|percent"

Return the cellSpacing property:

tableObject.cellSpacing

Tip:The cellSpacing property 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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the cellSpacing property


Example

Example

Change the space between table cells and the space between the cell edge and its content:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Example (example.com)</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>

Try it Yourself »


Table 对象参考手册Table Object Other Extensions