VOOZH about

URL: https://www.geeksforgeeks.org/css/css-max-height-property/

⇱ CSS max-height Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

CSS max-height Property

Last Updated : 28 Aug, 2024

The max-height property in CSS is used to set the maximum height of an element. If the content of the element is larger than the specified maximum-height then the content will overflow otherwise it has no effect. If the content of the element is smaller then it has no effect. The height property value can be overridden by the max-height property.

Syntax:

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

Property values:

  • none: It is the default value and does not contain max-height. It is synonymous to no maximum height specification. 
  • length: This property is used to define the max-height in length. The length can be set using px, em etc. 
  • initial: This property is used to set the value of the max_height to its default value.
  • inherit: This property is inherited from its parent. 

Example: In this example, we are using the max-height: none property.

Output:👁 max-height

Example: In this example, we use max-height: length; property.

Output:👁 max-height

Example: In this example, we are using max-height: initial property.

Output:👁 max-height

Supported Browsers: The browser supported by max-height property are listed below:

  • Google Chrome 18.0
  • Edge 12.0
  • Internet Explorer 7.0
  • Firefox 1.0
  • Opera 7.0
  • Safari 1.3
Comment