English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive List of CSS Properties

CSS max-Usage and examples of height attribute

max-The height CSS attribute specifies the maximum height of the content area of an element. This maximum height does not include padding, border, or margin.-For more information, please refer toCSS box model.

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.

Default Value:none
Applicable To:All elements except replaced embedded elements, table rows, and row groups
Inheritance:No
Animatable:Yes.Please refer to Animation Attributes.
Version:CSS 2、3
JavaScript Syntax:object.style.maxHeight="200px"

max-Syntax of height usage

The syntax of this attribute is as follows:

max-height: length | percentage | none | initial | inherit

The following examples demonstrate how to use max-height attribute.

  p {
   max-height: 100px;
  }
  div {
   height: 200px;
   max-height: 100px;
  }
Test See‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
lengthSpecify the maximum height in units such as px, pt, cm, em, etc. Negative values are not allowed.
percentageSpecify the maximum height as a percentage. The percentage is calculated relative to the height of the element's containing block. Negative percentage values are not allowed.
noneHeight has no maximum value. This is the default value.
initialSet this attribute to its default value.
inheritIf specified, the associated elements will use the max of its parent element-The value of the height attribute.

Browser Compatibility

max-Browser compatibility of height attribute, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 7+

  • Apple Safari 1+

  • Opera 7+

Read More

Please refer to the tutorials related to the following content:CSS Box Model,CSS Dimensions.

Related Attributes:height,min-height.