Edit on
<h2>Using <code>vertical-align</code> on table cells</h2>

<table class="vtable">
  <tbody>
    <tr>
      <td class="td1" rowspan="2">Example text.
        <div></div>
      </td>
      <td class="td2">Example text.</td>
    </tr>
    <tr>
      <td>Example text.</td>
    </tr>
    </tfoot>
</table>

<div class="vtbtn">
  <button>baseline</button>
  <button>top</button>
  <button>middle</button>
  <button>bottom</button>
</div>

<p>Press the buttons to change the <code>vertical-align</code> value of the blue table cell.</p>

<p class="p">Demo by Louis Lazaris. <a href="http://www.sitepoint.com/12-little-known-css-facts-the-sequel" target="_blank">See article</a>.</p>
body {
  text-align: center;
}

table {
  margin: 20px auto;
}

table,
td,
th {
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border: solid 1px;
  text-align: center;
}

.vtable td {
  background: lightpink;
}

.vtable .td1 {
  vertical-align: middle;
  width: 50%;
  height: 100px;
  background: lightblue;
  padding: 20px;
  font-size: 40px;
}

.p {
  font-family: Arial, sans-serif;
  font-size: 14px;
  padding-top: 130px;
}
var vtbtn = document.querySelector('.vtbtn').querySelectorAll('button');

for (var i = 0; i < vtbtn.length; i++) {
  (function(index) {
    vtbtn[index].addEventListener('click', function() {
      document.querySelector('.vtable .td1').style.verticalAlign = vtbtn[index].innerHTML;
    });
  })(i);
}
Rerun