Javascript DOM CSS Style verticalAlign Property get

Introduction

Return the vertical alignment of a <td> element:

alert(document.getElementById("myTd").style.verticalAlign);

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table {//ww w .  j  av  a2  s  . c o  m
  border: 1px solid black;
  height: 100px;
}
</style>
</head>
<body>

<table>
  <tr>
    <td id="myTd" style="vertical-align:top;">Some example text</td>
  </tr>
</table>
<br>

<button type="button" onclick="myFunction()">Return vertical alignment</button>
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = document.getElementById("myTd").style.verticalAlign;
}
</script>

</body>
</html>



PreviousNext

Related