min-width

Summary

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

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

  • Initial value 0
  • Applies to all elements but non-replaced inline elements, table rows, and row groups
  • Inherited no
  • Percentages refer to the width of the containing block
  • 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-width: 3.5em
min-width: 10%
min-width: max-content
min-width: min-content
min-width: fit-content
min-width: fill-available

min-width: inherit

Values

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

Examples

table { min-width: 75%; }

form { min-width: 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-width 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 1.0 (1.0) 7.0 4.0 2.0.2 (416), buggy before
applies to <table> [1] Not supported (Yes) Not supported (Yes) Not supported
max-content, min-content, fit-content, and fill-available 24.0 -webkit [3] 3.0 (1.9) -moz [2] Not supported Not supported Not supported [3]
auto 21.0 16.0 (16.0)
Removed in 22.0 (22.0)
Not supported 12.10 Not supported
auto as initial value 21.0 18.0 (18.0)
Removed in 22.0 (22.0)
Not supported 12.10 Not supported
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ? ?

Notes

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

[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 Intrinsic.

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

See also

Document Tags and Contributors

Last updated by: teoli,
Hide Sidebar