/

HTML / CSS / JavaScript Tutorial

CSS Property: min-height

[this page | pdf | back links]

The CSS (CSS2) min-height property sets the minimum height an element can become. It overrides the height property and the max-height property.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

length

A CSS length

%

Defined as a percentage of that of the containing block

none

(default value). No limit

 

Default Value:

none

JavaScript syntax:

e.g. object.style.minHeight="100px"

Inherited:

No

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
p {width: 300px; overflow: auto; background-color: yellow;}
p.x1 {min-height: 60px;}
</style>
</head>
<body>
<p>Element with default property</p>
<p class="x1">Property set using in-file HTML style</p>
<p id="x2">Property set using JavaScript</p>

<script>
document.getElementById("x2").style.minHeight = "60px";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyMinHeight() {
  var x = document.createElement("DIV"); x.style.minHeight = "60px"; return (window.getComputedStyle(x, null).minHeight == "60px");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile