td/th vAlignPropiedad
Objeto td/th
Definición y uso
La propiedad vAlign establece o devuelve la alineación vertical de los datos dentro de una celda.
Sintaxis
Establecer la propiedad vAlign:
tdObject.vAlign="baseline|bottom|middle|top"
O bien
thObject.vAlign="baseline|bottom|middle|top"
O bien
thObject.vAlign="baseline|bottom|middle|top"
Devolver la propiedad vAlign:
tdObject.vAlign
O bien
thObject.vAlign
O bien
thObject.vAlign
| Valor | Descripción |
|---|---|
| baseline | Alinear con la línea base. |
| bottom | Alinear el contenido a la parte inferior. |
| middle | Centrar el contenido. |
| top | Alinear el contenido a la parte superior. |
Compatibilidad del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad vAlign
Ejemplo
Ejemplo
El siguiente ejemplo cambia la alineación vertical de los datos dentro de la celda:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function displayResult(){
document.getElementById('td1').vAlign="top";
document.getElementById('td2').vAlign="top";
document.getElementById('td3').vAlign="top";
}
</script>
</head>
<body>
<table width="50%" border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Text</th>
</tr>
<tr>
<td id="td1">Peter</td>
<td id="td2">Griffin</td>
<td id="td3">Hola, mi nombre es Peter, necesito un texto largo para demostrar, necesito un texto largo para demostrar.</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Alinear el contenido arriba</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function displayResult(){
document.getElementById('td1').vAlign="top";
document.getElementById('td2').vAlign="top";
document.getElementById('td3').vAlign="top";
}
</script>
</head>
<body>
<table width="50%" border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Text</th>
</tr>
<tr>
<td id="td1">Peter</td>
<td id="td2">Griffin</td>
<td id="td3">Hola, mi nombre es Peter, necesito un texto largo para demostrar, necesito un texto largo para demostrar.</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Alinear el contenido arriba</button>
</body>
</html>
Pruébalo »
Objeto td/th Otras extensiones