Revision 293472 of min-width

  • Revision slug: CSS/min-width
  • Revision title: min-width
  • Revision id: 293472
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The min-width CSS property is used to set the minimum width of a given element. It prevents the used value of the {{ Cssxref("width") }} property from becoming smaller than the value specified for min-width.

The value of min-width overrides both {{ Cssxref("max-width") }} and {{ Cssxref("width") }}.

  • {{ Xref_cssinitial() }}: auto (which always resolves to 0 on non-flex items)
  • Applies to: block level and replaced elements, for <table> see {{ Anch("Browser compatibility") }} below
  • {{ Xref_cssinherited() }}: no
  • Percentages: refer to the width of the containing block
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: the percentage as specified or the absolute length

Syntax

min-width:  <length> | <percentage> | auto | max-content | min-content | fit-content | available (or fill-available)

Values

 
auto {{ experimental_inline() }}
On a flex item, this keyword indicates a minimum size of the min-content size; on all other items, it resolves to 0.
<length>
See {{ Xref_csslength() }} for possible units. Negative values make the declaration invalid.
<percentage>
Specified as a {{ Xref_csspercentage() }} of containing block's width. Negative values make the declaration invalid.
max-content {{ experimental_inline() }}
The intrinsic preferred width.
min-content {{ experimental_inline() }}
The intrinsic minimum width.
available or fill-available{{ experimental_inline() }}
The containing block width minus horizontal margin, border and padding. Two experimental specs, CSS3 Box and CSS3 Writing Modes, have a different name for this value. It is yet unclear which name will be selected in fine. Meanwhile, only prefixed version should be used.
fit-content {{ experimental_inline() }}
According CSS3 Box, this is a synonym of min-content. CSS3 Writing Modes defines a more complex algorithm, but no browser implements it, even in an experimental way.

Examples

table { min-width: 75%; }

form { min-width: 0; }

Specifications

Specification Status Comment
{{ SpecName('CSS3 Writing Modes', '#intrinsic-sizing', 'min-width') }} {{ Spec2('CSS3 Writing Modes') }} Adds the max-content, min-content, fit-content, and fill-available keywords.
It still is unclear which one of the two competing definition, the one of CSS3 Box or the one of CSS3 Writing Modes, will be selected.
{{ SpecName('CSS3 Box', '#min-max', 'min-width') }} {{ Spec2('CSS3 Box') }} Adds the max-content, min-content, fit-content, and available keywords.
It still is unclear which one of the two competing definition, the one of CSS3 Box or the one of CSS3 Writing Modes, will be selected.
{{ SpecName('CSS3 Flexbox', '#min-auto', 'min-width') }} {{ Spec2('CSS3 Flexbox') }} Adds the auto keyword and uses it as the initial value.
{{ SpecName('CSS3 Transitions', '#animatable-css', 'min-width') }} {{ Spec2('CSS3 Transitions') }} Defines min-width as animatable.
{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'min-width') }} {{ Spec2('CSS2.1') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.0) 7.0 4.0 2.0.2 (416), buggy before
applies to <table> [1] no yes no yes no
max-content, min-content, fit-content, and (fill-)available {{ experimental_inline() }} no [3] {{ CompatGeckoDesktop("1.9") }} {{ property_prefix("-moz") }} [2] no no no [3]
auto 21.0 no no no no
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-width 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] Gecko experimentally implements the definitions given in CSS3 Basic Box. This one defines available and not fill-available. Also the definition of fit-content is simpler than in CSS3 Writing Modes.

[3] WebKit implements an earlier proposal, the keyword intrinsic.

See also

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

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>min-width</code> CSS property is used to set the minimum width of a given element. It prevents the used value of the {{ Cssxref("width") }} property from becoming smaller than the value specified for <code>min-width</code>.</p>
<p>The value of <code>min-width </code>overrides both {{ Cssxref("max-width") }} and {{ Cssxref("width") }}.</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, for <code>&lt;table&gt;</code> see {{ Anch("Browser compatibility") }} below</li>
  <li><dfn>{{ Xref_cssinherited() }}:</dfn> no</li>
  <li><dfn>Percentages:</dfn> refer to the width 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">Syntax</h2>
<pre>
min-width:  &lt;length&gt; | &lt;percentage&gt; | auto | max-content | min-content | fit-content | available (or fill-available)</pre>
<h2 id="Values">Values</h2>
<dl>
  <dt>
    &nbsp;</dt>
  <dt>
    <code>auto</code> {{ experimental_inline() }}</dt>
  <dd>
    On a&nbsp;<a href="/en/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary" title="/en/CSS/Using_CSS_flexible_boxes#Flexible_boxes_vocabulary">flex&nbsp;</a><a href="/en/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 min-content size; on all other items, it resolves to <code>0.</code></dd>
  <dt>
    <code>&lt;length&gt;</code></dt>
  <dd>
    See {{ Xref_csslength() }} for possible units. Negative values make the declaration invalid.</dd>
  <dt>
    <code>&lt;percentage&gt;</code></dt>
  <dd>
    Specified as a {{ Xref_csspercentage() }} of containing block's width. Negative values make the declaration invalid.</dd>
  <dt>
    <code>max-content</code> {{ experimental_inline() }}</dt>
  <dd>
    The intrinsic preferred width.</dd>
  <dt>
    <code>min-content</code> {{ experimental_inline() }}</dt>
  <dd>
    The intrinsic minimum width.</dd>
  <dt>
    <code>available</code> or <code>fill-available</code>{{ experimental_inline() }}</dt>
  <dd>
    The containing block width minus horizontal margin, border and padding. Two experimental specs, CSS3 Box and CSS3 Writing Modes, have a different name for this value. It is yet unclear which name will be selected <em>in fine<code>.</code></em> Meanwhile, only prefixed version should be used.</dd>
  <dt>
    <code>fit-content</code> {{ experimental_inline() }}</dt>
  <dd>
    According CSS3 Box, this is a synonym of <code>min-content.</code> CSS3 Writing Modes defines a more complex algorithm, but no browser implements it, even in an experimental way.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre>
table { min-width: 75%; }

form { min-width: 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 Writing Modes', '#intrinsic-sizing', 'min-width') }}</td>
      <td>{{ Spec2('CSS3 Writing Modes') }}</td>
      <td>Adds the <code>max-content</code>, <code>min-content</code>, <code>fit-content</code>, and <code>fill-available</code> keywords.<br />
        <em>It still is unclear which one of the two competing definition, the one of CSS3 Box or the one of CSS3 Writing Modes, will be selected.</em></td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Box', '#min-max', 'min-width') }}</td>
      <td>{{ Spec2('CSS3 Box') }}</td>
      <td>Adds the <code>max-content</code>, <code>min-content</code>, <code>fit-content</code>, and <code>available</code> keywords.<br />
        <em>It still is unclear which one of the two competing definition, the one of CSS3 Box or the one of CSS3 Writing Modes, will be selected.</em></td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Flexbox', '#min-auto', 'min-width') }}</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-width') }}</td>
      <td>{{ Spec2('CSS3 Transitions') }}</td>
      <td>Defines <code>min-width</code> as animatable.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'min-width') }}</td>
      <td>{{ Spec2('CSS2.1') }}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_Compatibility" name="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>1.0 (1.0)</td>
        <td>7.0</td>
        <td>4.0</td>
        <td>2.0.2 (416), buggy before</td>
      </tr>
      <tr>
        <td>applies to <code>&lt;table&gt; </code>[1]</td>
        <td>no</td>
        <td>yes</td>
        <td>no</td>
        <td>yes</td>
        <td>no</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>no [3]</td>
        <td>{{ CompatGeckoDesktop("1.9") }} {{ property_prefix("-moz") }} [2]</td>
        <td>no</td>
        <td>no</td>
        <td>no [3]</td>
      </tr>
      <tr>
        <td><code>auto</code></td>
        <td>21.0</td>
        <td>no</td>
        <td>no</td>
        <td>no</td>
        <td>no</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-width</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>
<p>[2] Gecko experimentally implements the definitions given in CSS3 Basic Box. This one defines <code>available</code> and not <code>fill-available</code>. Also the definition of <code>fit-content</code> is simpler than in CSS3 Writing Modes.</p>
<p>[3] WebKit implements an earlier proposal, the keyword <code>intrinsic</code>.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ Cssxref("width") }}, {{ Cssxref("max-width") }}, {{ Cssxref("min-height") }}</li>
  <li>The <a href="/en/CSS/box_model" title="en/CSS/box_model">box model</a>, {{ Cssxref("box-sizing") }}</li>
</ul>
Revert to this revision