Set the maximum height that a box can be with CSS


The max-height property is used to set a maximum height that a box can be. The value of the max-height property can be a number, a length, or a percentage.

Example

<html>
   <head>
   </head>
   <body>
      <p style = "width:400px; max-height:10px; border:2px solid green; padding:10px; margin:15px;">
         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>
      <br>
      <br>
      <br>
      <img alt = "logo" src = "/css/images/logo.png" width = "210" height = "100" />
   </body>
</html>

Updated on: 04-Mar-2020

88 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements