Style minHeightProperty
Style Object
Definition and Usage
The minHeight property sets or returns the minimum height of an element.
The minHeight property only takes effect on block-level elements or elements with absolute/fixed positioning.
Syntax
Set the minHeight property:
Object.style.minHeight="length|%|inherit"
Return the minHeight property:
Object.style.minHeight
| Value | Description |
|---|---|
| length | Defines the minimum height using units such as px, cm. The default is 0. |
| % | Defines the minimum height as a percentage of the parent element. |
| inherit | The value of the minHeight property is inherited from the parent element. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the minHeight property.
Note:IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Set the minimum height of an element:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.minHeight="100px";
}
</script>
</head>
<body>
<p style="background:red;" id="p1">This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</p>
<input type="button" onclick="displayResult()" value="Set the minimum height of the element">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.minHeight="100px";
}
</script>
</head>
<body>
<p style="background:red;" id="p1">This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text.</p>
<input type="button" onclick="displayResult()" value="Set the minimum height of the element">
</body>
</html>
Try it Yourself »
Style Object Other Extensions