I know how to align text vertically inside a div, but I'm not sure how to do this if the div has a percentage height and width. Here is my code:
<div id="header">
<h1>Home</h1>
</div>
#header {
background-color: red;
color: white;
text-align: center;
vertical-align: middle;
width: 100%;
height: 15%;
}
Now on my webpage, the text in the div was aligned horizontally, but not vertically. How to fix this problem? Can you also try to explain your answers and keep them as simple as possible (I'm still relatively new to HTML / CSS). Thank.
source
share