Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Table cellSpacing property

Table cellSpacing property

Table Object Reference 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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

<

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 »


Table Object Reference Table object