HTML Element Style How to - Vertical align text within a list containing superscript








Question

We would like to know how to vertical align text within a list containing superscript.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from   w ww  .  ja v a2  s .c o m-->
  list-style: none;
}

li {
  background: red;
  height: 50px;
  margin: 3px 0;
  padding: 5px 0;
}

li span:first-child {
  height: 100%;
}

li span {
  vertical-align: middle;
  display: inline-block;
}
</style>
</head>
<body>
  <ul>
    <li><span></span><span>Shape: Rectangle<span></li>
    <li><span></span><span>Length: 5m</span></li>
    <li><span></span><span>Breadth: 3m</span></li>
    <li><span></span><span>Area: 15m<sup>2</sup></span></li>
    <li><span></span><span>Color:</span> <span>Blue</span></li>
  </ul>
</body>
</html>

The code above is rendered as follows: