Table cellPaddingPropiedad
Objeto Table
Definición y uso
La propiedad cellpadding especifica el espacio en blanco entre el borde de la celda y su contenido.
Sintaxis
Establecer la propiedad cellPadding:
tableObject.cellPadding="number|percent"
Devolver la propiedad cellPadding:
tableObject.cellPadding
Consejo:La propiedad cellPadding no tiene un valor predeterminado.
| Valor | Descripción |
|---|---|
| number | Establecer el espacio en blanco entre el borde de la celda y su contenido en píxeles |
| percent | Establecer el espacio en blanco entre el borde de la celda y su contenido en porcentaje |
Compatibilidad con navegadores
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad cellPadding
Ejemplo
Ejemplo
Cambiar el espacio en blanco entre las celdas de la tabla y el espacio en blanco entre el borde de la celda y su contenido:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (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()">Modificar el relleno de la celda</button>
<button type="button" onclick="spacing()">Modificar el espaciado de las celdas</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (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()">Modificar el relleno de la celda</button>
<button type="button" onclick="spacing()">Modificar el espaciado de las celdas</button>
</body>
</html>
Pruébalo »
Objeto Table Otras extensiones