max-height
will cap the DIV's height at 500px but allow it to be smaller if it does not take up 500px.
height: 100%
will inherit the height from the parent element's height.
Use height: 500px
if you want the DIV to be 500px in height.
I have included an example. For both the .outer
and .inner
DIVs un-comment or comment out the height values. You will see that if the height of the parent DIV is not set, then height: 100%
will not match the height of the parent and will default to it's own content's height.
.outer {
background-color: blue;
height: 100px;
}
.inner {
background-color: red;
color: white;
/*height: 100%;*/
text-align: center;
width: 50%;
}
<div class="outer">
<div class="inner">
Inner
</div>
</div>