I have the following HTML code:
p.error {
  color: red;
  padding: 5%;
  margin-left: 20%;
  margin-right: 20%;
  font-size: 300%;
  height: 100%;
  box-shadow: 3px 3px 20px 3px #545454;
  text-align: center;
  background-color: #f1f1f1;
}
div.alert {
  padding-top: 50%;
}<div class="alert">
  <p class="error">Error: Permission denied!</p>
</div>Which my browser (Google Chrome Version 57.0.2987.133) compiles to this:
 I finally got it to vertically center the div by using:
I finally got it to vertically center the div by using:
div.alert{
    padding-top: 22.5%;
}
By further testing, I noticed that the browser uses the width instead of the height for padding-top.
My question: Why does the browser compile the HTML-code like this and how can I get it to vertically center the div by using 50%?
 
     
     
     
    