Table cellPaddingProperty

Table 对象参考手册Table Object

Definition and Usage

The cellpadding property specifies the space between the cell edge and its content.

Syntax

Set the cellPadding property:

tableObject.cellPadding="number|percent"

Return the cellPadding property:

tableObject.cellPadding

Tip:The cellPadding property has no default value.

Value Description
number Sets the space between the cell edge and its content in pixels
percent Sets the space between the cell edge and its content as a percentage


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the cellPadding 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 Tutorial(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