HTML Element Style How to - Align paragraph vertically








Question

We would like to know how to align paragraph vertically.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from ww w .  j a v  a 2 s.  c  om-->
  border: 3px solid red;
  line-height: 300px;
}

p {
  display: inline-block;
  line-height: 20px;
  width: 100%;
  text-align: center;
  background: yellow;
}
</style>
</head>
<body>
  <div>
    <p>
      Some text here <br> Some more text here.
    </p>
  </div>
</body>
</html>

The code above is rendered as follows: