
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
The min-height Property in CSS
We can define a fixed min-height for an element’s content box using CSS min-height property which does not allows the element’s content box to be smaller even if height is lesser than min-height.
Syntax
The syntax of CSS min-height property is as follows −
Selector { min-height: /*value*/ }
Example
Let’s see an example for CSS min-height property −
<!DOCTYPE html> <html> <head> <title>CSS min-height Property</title> </head> <style> * { padding: 2px; margin:5px; } button { border-radius: 10px; } #containerDiv { width:70%; margin: 0 auto; padding:20px; background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%); text-align: center; border-radius: 10px; } #contentDiv{ min-height:150px; } </style> <body> <div id="containerDiv"> <div id="contentDiv"> This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. </div> <button onclick="add()" class="btn">Set minHeight</button> </div> <script> function add() { document.querySelector('#contentDiv').style.minHeight = "100px"; } </script> </body> </html>
Output
Following is the output for above code −
Before clicking ‘Set minHeight’ button −
After clicking ‘Set minHeight’ button −
Example
Let’s see another example for the CSS min-height property −
<!DOCTYPE html> <html> <head> <title>CSS min-height Property</title> </head> <style> * { padding: 2px; margin:5px; } button { border-radius: 10px; } #containerDiv { width:70%; margin: 0 auto; padding:20px; background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%); text-align: center; border-radius: 10px; } #contentDiv1, #contentDiv2{ width:50%; border: 2px solid black; margin: 0 auto; } </style> <body> <div id="containerDiv"> <div id="contentDiv1"> This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. </div> <div id="contentDiv2"> This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy. </div> <button onclick="add()" class="btn">Set minHeight</button> </div> <script> function add() { document.querySelector('#contentDiv1').style.minHeight = "95px"; } </script> </body> </html>
Output
Following is the output for above code −
Before clicking ‘Set minHeight’ button −
After clicking ‘Set minHeight’ button −
- Related Articles
- CSS min-height
- The min-width Property in CSS
- CSS min-width property
- Perform Animation on CSS min-height
- The max-height Property in CSS
- CSS height property
- Set min-height and max-height of an element using CSS
- Animate CSS height property
- CSS line-height property
- CSS max-height property
- Usage of height property with CSS
- Perform Animation on CSS line-height property
- Add CSS transition effect for both the width and height property
- HTML DOM Meter min Property
- HTML DOM Input Week min Property

Advertisements