CSS - max-height


Description:

The max-height property is used to set an upper bound on the height of an element.

Possible Values:

  • length: Any length unit. The element can never have a value for height which exceeds this distance.
  • percentage: Limits the element's height to be at most this percentage of the height of the containing block.
  • none: There is no limit to the height of the element.

Applies to:

All the HTML elements except non-replaced inline elements and table elements.

DOM Syntax:

object.style.maxHeight="50px"

Example:

Here is the example:

<p style="width:400px; max-height:10px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
</p>
<img alt="logo" src="images/css.gif" width="95" height="84" />
     

This will produce following result:

This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px

logo





Spacer Bottom Left Corner ImageBottom Right Corner Image
Valid XHTML 1.0 Strict  Valid CSS! Check the accessibility of this site according to U.S. Section 508