Page Widget How to - Vertical alignment with h1








Question

We would like to know how to vertical alignment with h1.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
h1 {<!--from   ww w  .  ja  va 2  s . c  om-->
  background: red;
  font-size: 40px;
  line-height: 80px;
}
.icon {
  background: aqua;
  border: 1px solid blue;
  border-radius: 3px;
  padding: 0px 4px;
  width: auto;
  display: inline-block;
  font-size: 20px;
  line-height: 40px;
  vertical-align: 7px;
}
</style>
</head>
<body>
  <h1>
    <span class="icon">Icon</span> Some Text related to the icon
  </h1>
</body>
</html>

The code above is rendered as follows: