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:
- CSS max-height
- CSS min-height
- CSS max-width
- CSS min-width
- CSS Width
- CSS Height
- CSS Height & Width (All Properties)