max-height
Specifies the maximum height of an element.
Sample Code
div.test { max-height: 500px;}
div.test1 { max-height: 0;}
Available Values
| Value | Description |
|---|---|
| none | No maximum value is specified. The initial value is 'none'. |
| number | A numeric value. Commonly used units are 'px' and '%'. Negative values are not allowed. When specified as '%', the reference size is the height of the containing block. |
Browser Display Result
<div style="max-height: 100px; background-color: #ff0;">This is a div element. 'max-height: 100px' is specified.</div>
<div style="height: 300px; border: solid 1px #f00;"> <div style="max-height: 80%; height: 300px; background-color: #ff0;">This is a div inside a div. The parent div (red border) has 'height: 300px'. This element (yellow background) has 'max-height: 80%' and 'height: 300px'. Its maximum height is relative to the parent's height, giving a maximum of '240px'. Since '240px' is less than 'height: 300px', this element's height becomes '240px'.</div> </div>
8
6
6 and earlier
Android Browser