Summary
The min-height
property is used to set the minimum height of a given element. It prevents the used value of the {{ Cssxref("height") }} property from becoming smaller than the value specified for min-height
.
The value of {{ Cssxref("min-height") }} overrides both {{ Cssxref("max-height") }} and {{ Cssxref("height") }}.
{{cssinfo}}
Syntax
/* <length> value */ min-height: 3.5em; /* <percentage> value */ min-height: 10%; /* Keyword values */ min-height: max-content; min-height: min-content; min-height: fit-content; min-height: fill-available; /* Global values */ min-height: inherit; min-height: initial; min-height: unset;
Values
<length>
- The fixed minimum height. See {{cssxref("<length>")}} for possible units. Negative values make the declaration invalid.
<percentage>
- The fixed minimum height expressed as a {{cssxref("<percentage>")}} of containing block's height. Negative values make the declaration invalid.
max-content
{{ experimental_inline() }}- The intrinsic preferred height.
min-content
{{ experimental_inline() }}- The intrinsic minimum height.
fill-available
{{ experimental_inline() }}- The containing block height minus horizontal margin, border and padding. Some browsers implement an ancient name for this keyword,
available
. fit-content
{{ experimental_inline() }}- According CSS3 Box, this is a synonym of
min-content.
CSS3 Sizing defines a more complex algorithm, but no browser implements it, even in an experimental way.
Formal syntax
{{csssyntax}}
Examples
table { min-height: 75%; } form { min-height: 0; }
Specifications
Specification | Status | Comment |
---|---|---|
{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'min-height') }} | {{ Spec2('CSS3 Sizing') }} | Adds the max-content , min-content , fit-content , and fill-available keywords.Both CSS3 Box and CSS3 Writing Modes drafts defined at some point these keywords. These drafts are superseded by this spec. |
{{ SpecName('CSS3 Flexbox', '#min-auto', 'min-height') }} | {{ Spec2('CSS3 Flexbox') }} | An earlier revision of the spec added the auto keyword and used it as the initial value. The CSSWG subsequently resolved to revert this change, however. As of March 29, 2013, the latest Editor's Draft doesn't modify the min-width property anymore (i.e. it no longer introduces the auto value). |
{{ SpecName('CSS3 Transitions', '#animatable-css', 'min-height') }} | {{ Spec2('CSS3 Transitions') }} | Defines min-height as animatable. |
{{ SpecName('CSS2.1', 'visudet.html#min-max-heights', 'min-height') }} | {{ Spec2('CSS2.1') }} | Initial definition |
Browser compatibility
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | {{ CompatGeckoDesktop("1.9") }} | 7.0 [3] | 4.0 | 1.0 2.0.2 (416) for positioned elements |
applies to <table> [1] |
{{ CompatNo() }} | {{ CompatVersionUnknown() }} | {{ CompatNo() }} | {{ CompatVersionUnknown() }} | {{ CompatNo() }} |
max-content , min-content , fit-content , and fill- available {{ experimental_inline() }} |
{{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} | {{ CompatNo() }} | 9 |
auto {{obsolete_inline(22)}} |
21.0 | {{ CompatGeckoDesktop("16.0") }} | {{ CompatNo() }} | 12.10 | {{ CompatNo() }} |
auto as initial value{{obsolete_inline(22)}} |
21.0 | {{ CompatGeckoDesktop("18.0") }} | {{ CompatNo() }} | 12.10 | {{ CompatNo() }} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | 9 |
[1] CSS 2.1 explicitly leaves the behavior of min-height
with {{ HTMLElement("table") }} undefined. Therefore any behavior is CSS2.1-compliant; newer CSS specifications may define this behavior, so Web developers shouldn't rely on a specific one now.
[2] Due to bug ({{bug("307866")}}) Firefox doesn't handle min-height
on elements with display: table-*
.
[3] In Internet Explorer 10-11 (but not 12+), a min-height
declaration on a column-direction flex container doesn't apply to the container's flex items. See Flexbug #3 for more info.
See also
- {{ Cssxref("width") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}
- The box model, {{ Cssxref("min-width") }}, {{ Cssxref("box-sizing") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}