CSS max-height

Please Share On:

Defination:

CSS max-height property is used to assign the maximum height of an element.

Syntax:

max-height: 500px;

Source Code:

See the below example without and with min-height property.

<!DOCTYPE html>
<html>
  <head>
    <style>
    .paragraph1{
      border: 2px dashed red;
      background-color: pink;
      text-align:center;
    }

    .paragraph2{
      border: 2px dashed red;
      background-color: orange;
      text-align:center;
      max-height: 20px;
    }
    </style>
  </head>

  <body>
    <div class="paragraph1">This is a first paragraph without set maximum height.</div>
    <div class="paragraph2">This is a second paragraph with max-height: 20px; </div>  
  </body>
</html>

Output:


Donate to support writers


You may be interested in the following topics:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial