Page Widget How to - Make text align middle








Question

We would like to know how to make text align middle.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--   ww w  .  jav  a2s.co  m-->
  height: 70px;
  background-color: red;
}

div h2 {
  line-height: 70px;
  text-align: center;
}
</style>
</head>
<body>
  <div>
    <h2>Test</h2>
  </div>
</body>
</html>

The code above is rendered as follows: