Table cellSpacing property
Table object
Definition and Usage
The cellSpacing property can be set or returned to indicate the amount of space (in pixels) between cells in a table.
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





All major browsers support the cellSpacing property
Example
Example
Change the space between table cells and the space between the cell border and its content:
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Runoob Tutorial(runoob.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
<
tdcell 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 »
Table object