min-height

Summary

The min-height CSS property is used to set the minimum height of a given element. It prevents the used value of the height property from becoming smaller than the value specified for min-height.

The value of min-height overrides both max-height and height.

  • Initial value 0
  • Applies to all elements but non-replaced inline elements, table columns, and column groups
  • Inherited no
  • Percentages The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the percentage value is treated as 0.
  • Media visual
  • Computed value the percentage as specified or the absolute length
  • Animatable yes, as a length, percentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
  • Canonical order the unique non-ambiguous order defined by the formal grammar

Syntax

Formal syntax: <length> | <percentage> | max-content | min-content | fit-content | fill-available
min-height: 3.5em
min-height: 10%
min-height: max-content
min-height: min-content
min-height: fit-content
min-height: fill-available

min-height: inherit

Values

<length>
The fixed minimum height. See <length> for possible units. Negative values make the declaration invalid.
<percentage>
The fixed minimum height expressed as a <percentage> of containing block's height. Negative values make the declaration invalid.
max-content
The intrinsic preferred height.
min-content
The intrinsic minimum height.
fill-available
The containing block height minus horizontal margin, border and padding. Some browsers implement an ancient name for this keyword, available.
fit-content
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.

Examples

table { min-height: 75%; }

form { min-height: 0; }

Specifications

Specification Status Comment
CSS Intrinsic & Extrinsic Sizing Module Level 3 Working Draft 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.
CSS Flexible Box Layout Module Candidate Recommendation 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).
CSS Transitions Working Draft Defines min-height as animatable.
CSS Level 2 (Revision 1) Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 3.0 (1.9) 7.0 4.0 1.0
2.0.2 (416) for positioned elements
applies to <table> [1] Not supported (Yes) Not supported (Yes) Not supported
max-content, min-content, fit-content, and fill-available Not supported Not supported Not supported Not supported Not supported
autoObsolete since Gecko 22 21.0 16.0 (16.0) Not supported 12.10 Not supported
auto as initial valueObsolete since Gecko 22 21.0 18.0 (18.0) Not supported 12.10 Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

Notes

[1] CSS 2.1 explicitly leaves the behavior of min-height with <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.

See also

Hide Sidebar