Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Box Model and Sizing

The min-width property

Reference for the CSS min-width property: set a floor under an element's width, use it with percentages and flex items, and fix overflowing flex children.

The min-width property sets a lower limit for an element's width. If the computed width would be smaller, the box is widened to min-width. It beats max-width only in one case: when the two conflict, min-width wins.

It is most useful to stop flexible elements from becoming unreadably narrow, and it also has an important hidden role in flexbox and grid: the automatic minimum size of items.

CSS
.button { min-width: 8rem; }
.flex-child { min-width: 0; }

Try it

A floor under a fluid width
min-width: 0 on flex items

In the first row the flex item refuses to shrink below its content, so the text sticks out past the frame. In the second row min-width: 0 lets the item shrink, and the ellipsis appears.

Syntax

CSS
min-width: auto
         | <length-percentage [0,โˆž]>
         | min-content | max-content | fit-content | fit-content(<length-percentage>)
         | stretch;
  • Initial value: auto
  • Applies to: all elements except non-replaced inline elements, table rows and row groups
  • Inherited: no
  • Animatable: yes, as a length or percentage
  • Computed value: a percentage or auto as specified, otherwise an absolute length

Values

Value Description
auto Computes to 0 for most boxes. For flex and grid items it is the content-based minimum size.
<length> A fixed floor such as 200px or 12rem.
<percentage> A percentage of the containing block's width.
min-content, max-content, fit-content Content-based floors.
stretch Fill the available space. Newer, with limited support.

Usage notes

  • min-width overrides max-width and width. The order is: the used width is clamped by max-width, then raised by min-width.
  • Flexbox overflow fix. A flex item's min-width: auto prevents it from shrinking below its content. Long words, URLs, code blocks and images then overflow. Setting min-width: 0 (or overflow: hidden) lets the item shrink.
  • Grid has the same behavior. Use minmax(0, 1fr) instead of 1fr for the same reason.
  • Don't force widths on small screens. A large min-width can create horizontal scrolling on phones. Prefer min-width: min(20rem, 100%).
  • Tables. On table cells it acts as a hint in practice; test across browsers.
  • Logical equivalent: min-inline-size.

Browser support

Supported in every browser. min-width: auto for flex items is implemented consistently in all current browsers.