I use this css to set a <div> to maximum height
Can anyone give me a general answer, what’s the difference between height: 100% and min-height: 100% ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s an explanation from the W3C (link):
To summarize: Basically, if the min-height is greater than what the height would otherwise be (whether an explicit height is specified or not), then the min-height is used as the height. If the min-height is less than what the height would otherwise be, then the min-height has no effect.
For the specific case you give, specifying
height:100%makes the height of the element equal to the height of the containing block. (However this could potentially be overruled, for instance if you also specifiedmax-height:50%.) Specifyingmin-height:100%means that if the computed height is less than 100%, in fact even if you explicitly specified a height less than 100%, it is treated as if you saidheight:100%. Note that one key difference is that max-height can overrule height but cannot overrule min-height (because max-height is considered after height but before min-height according to the W3C recommendation as quoted above).