Style tableLayoutPropiedad
Objeto Style
Definición y uso
La propiedad tableLayout establece o devuelve las reglas del algoritmo de visualización de las celdas, filas y columnas de una tabla.
Sintaxis
Establecer la propiedad tableLayout:
Object.style.tableLayout="automatic|fixed|inherit"
Devolver la propiedad tableLayout:
Object.style.tableLayout
| Valor | Descripción |
|---|---|
| auto | Predeterminado. El ancho de las columnas lo establece el contenido de las celdas.
|
| fixed | El ancho de las columnas se establece mediante el ancho de la tabla y el ancho de las columnas (no mediante el contenido de las celdas).
|
| inherit | El valor de la propiedad tableLayout se hereda del elemento padre. |
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad tableLayout.
Nota:IE7 y versiones anteriores no admiten el valor "inherit". IE8 solo admite "inherit" si se especifica !DOCTYPE. IE9 admite "inherit".
Ejemplo
Ejemplo
Establecer un diseño de tabla fijo:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").style.tableLayout="fixed";
}
</script>
</head>
<body>
<table id="myTable" width="300" border="1">
<thead>
<th>Encabezado de tabla</th>
<th>Encabezado de tabla</th>
</thead>
<tbody>
<tr>
<td>Este es un texto. Este es un texto.</td>
<td>Este es otro texto</td>
</tr>
</tbody>
</table>
<br>
<button type="button" onclick="displayResult()">Configurar diseño fijo de tabla</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").style.tableLayout="fixed";
}
</script>
</head>
<body>
<table id="myTable" width="300" border="1">
<thead>
<th>Encabezado de tabla</th>
<th>Encabezado de tabla</th>
</thead>
<tbody>
<tr>
<td>Este es un texto. Este es un texto.</td>
<td>Este es otro texto</td>
</tr>
</tbody>
</table>
<br>
<button type="button" onclick="displayResult()">Configurar diseño fijo de tabla</button>
</body>
</html>
Pruébalo »
Objeto Style Otras extensiones