You are here: Reference > CSS > properties > max-height

max-height property

Browser support:
Specifies the maximum height for the visible area of an element.
This property has effect only on block-level elements or on elements with absolute or fixed position. The max-height property contains only the pure height of the visible content, without the padding, scrollbar, border and the margin.
The height of an element can never be greater than the value specified by the max-height property.
Note that this property works in Internet Explorer only from version 7.
You can specify a range for the size of an element with the min-width, min-height, max-width and max-height properties. If you want to specify the exact size of an element, use the width and height properties.
JavaScript page for this property: maxHeight. You can find other example(s) there.

Possible values:

 One of the following values: 
height in non-negative length
The maximum height for the element in length units. For the supported length units, see the length page.
height in non-negative percentage
The maximum height for the element is the specified percentage of the height of the parent element.
Takes the value of this property from the computed style of the parent element.
No limit on the height of the element.
Default: none.

Example HTML code 1:

This example illustrates the use of the max-height property:
        .withMax {
            max-height: 50px;
            height: 100px;
            background: red;

        .withouMax {
            height: 100px;
            background: red;
    <p class="withMax">
        Element has height: 100px and max-height: 50px. As a result, it should be 50 pixels high.
    <p class="withouMax">
        Element has height: 100px. As a result, it should be 100 pixels high.
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content