mozilla

Revision 349371 of min-height

  • Revision slug: CSS/min-height
  • Revision title: min-height
  • Revision id: 349371
  • Created:
  • Creator: dag0911
  • Is current revision? No
  • Comment Replaced all the errant width references with height

Revision Content

{{ CSSRef() }}

Summary

The min-height CSS 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") }}.

  • {{ Xref_cssinitial() }} auto (which always resolves to 0 on non-flex items)
  • Applies to block level and replaced elements
  • {{ Xref_cssinherited() }} no
  • Percentages refer to the height of the containing block
  • Media {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }} the percentage as specified or the absolute length

Syntax

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

Values

auto
On a flex item, this keyword indicates a minimum size of the min-content size; on all other items, it resolves to 0.
<length>
The fixed minimum height. See {{ Xref_csslength() }} for possible units. Negative values make the declaration invalid.
<percentage>
The fixed minimum height expressed as a {{ Xref_csspercentage() }} 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.

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') }} Adds the auto keyword and uses it as the initial 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 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() }} {{ CompatNo() }}
auto 21.0 {{ CompatGeckoDesktop("16.0") }} {{ CompatNo() }} 12.10 {{ CompatNo() }}
auto as initial value 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() }} {{ CompatUnknown() }}

Notes

[1] CSS 2.1 explicitely 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.

See also

  • {{ Cssxref("width") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}
  • The box model, {{ Cssxref("min-width") }}, {{ Cssxref("box-sizing") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>min-height</code> CSS 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 <code>min-height</code>.</p>
<p>The value of {{ Cssxref("min-height") }} overrides both {{ Cssxref("max-height") }} and {{ Cssxref("height") }}.</p>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}</dfn> <code>auto</code> (which always resolves to <code>0</code> on non-flex items)</li>
  <li><dfn>Applies to</dfn> block level and replaced elements</li>
  <li><dfn>{{ Xref_cssinherited() }}</dfn> no</li>
  <li><dfn>Percentages</dfn> refer to the height of the containing block</li>
  <li><dfn>Media</dfn> {{ Xref_cssvisual() }}</li>
  <li><dfn>{{ Xref_csscomputed() }}</dfn> the percentage as specified or the absolute length</li>
</ul>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="/en-US/docs/CSS/Value_definition_syntax">Formal syntax</a>:  &lt;length&gt; | &lt;percentage&gt; | auto | max-content | min-content | fit-content | fill-available
</pre>
<pre>
min-height: 3.5em
min-height: 10%
min-height: auto
min-height: max-content
min-height: min-content
min-height: fit-content
min-height: fill-available
min-height: inherit
</pre>
<h3 id="Values" name="Values">Values</h3>
<dl>
  <dt>
    <code>auto</code></dt>
  <dd>
    On a&nbsp;<a href="/en-US/docs/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary" title="/en-US/docs/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary">flex&nbsp;</a><a href="/en-US/docs/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary" title="en/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary">item</a>, this keyword indicates a minimum size of the <code>min-content</code> size; on all other items, it resolves to <code>0.</code></dd>
  <dt>
    <code>&lt;length&gt;</code></dt>
  <dd>
    The fixed minimum height. See {{ Xref_csslength() }} for possible units. Negative values make the declaration invalid.</dd>
  <dt>
    <code>&lt;percentage&gt;</code></dt>
  <dd>
    The fixed minimum height expressed as a {{ Xref_csspercentage() }} of containing block's height. Negative values make the declaration invalid.</dd>
  <dt>
    <code>max-content</code> {{ experimental_inline() }}</dt>
  <dd>
    The intrinsic preferred height.</dd>
  <dt>
    <code>min-content</code> {{ experimental_inline() }}</dt>
  <dd>
    The intrinsic minimum height.</dd>
  <dt>
    <code>fill-available</code>{{ experimental_inline() }}</dt>
  <dd>
    The containing block height minus horizontal margin, border and padding. Some browsers implement an ancient name for this keyword, <code>available</code>.</dd>
  <dt>
    <code>fit-content</code> {{ experimental_inline() }}</dt>
  <dd>
    According CSS3 Box, this is a synonym of <code>min-content.</code> CSS3 Sizing defines a more complex algorithm, but no browser implements it, even in an experimental way.</dd>
</dl>
<h2 id="Examples" name="Examples">Examples</h2>
<pre class="brush: css">
table { min-height: 75%; }

form { min-height: 0; }
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'min-height') }}</td>
      <td>{{ Spec2('CSS3 Sizing') }}</td>
      <td>Adds the <code>max-content</code>, <code>min-content</code>, <code>fit-content</code>, and <code>fill-available</code> keywords.<br />
        <em>Both CSS3 Box and CSS3 Writing Modes drafts defined at some point these keywords. These drafts are superseded by this spec.</em></td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Flexbox', '#min-auto', 'min-height') }}</td>
      <td>{{ Spec2('CSS3 Flexbox') }}</td>
      <td>Adds the <code>auto</code> keyword and uses it as the initial value.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Transitions', '#animatable-css', 'min-height') }}</td>
      <td>{{ Spec2('CSS3 Transitions') }}</td>
      <td>Defines <code>min-height</code> as animatable.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS2.1', 'visudet.html#min-max-heights', 'min-height') }}</td>
      <td>{{ Spec2('CSS2.1') }}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1.0</td>
        <td>{{ CompatGeckoDesktop("1.9") }}</td>
        <td>7.0</td>
        <td>4.0</td>
        <td>1.0<br />
          2.0.2 (416) for positioned elements</td>
      </tr>
      <tr>
        <td>applies to <code>&lt;table&gt; </code>[1]</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatVersionUnknown() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatVersionUnknown() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td><code>max-content</code>, <code>min-content</code>, <code>fit-content</code>, and <code>fill-</code><code>available</code> {{ experimental_inline() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td><code>auto</code></td>
        <td>21.0</td>
        <td>{{ CompatGeckoDesktop("16.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>12.10</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td><code>auto</code> as initial value</td>
        <td>21.0</td>
        <td>{{ CompatGeckoDesktop("18.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>12.10</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE&nbsp;Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h3 id="Notes">Notes</h3>
<p>[1] CSS 2.1 explicitely leaves the behavior of <code>min-height </code>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.</p>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>{{ Cssxref("width") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}</li>
  <li>The <a href="/en-US/docs/CSS/box_model" title="en/CSS/box_model">box model</a>, {{ Cssxref("min-width") }}, {{ Cssxref("box-sizing") }}, {{ Cssxref("height") }}, {{ Cssxref("max-height") }}</li>
</ul>
Revert to this revision