· 6 min read
Why a flex item won't shrink, and why min-width: 0 fixes it
A flex item won't shrink below its content because min-width defaults to auto. Here is why ellipsis and scrolling break, and how min-width: 0 fixes it.

A flex item won't shrink below the width of its content because its default min-width is auto, not 0. A long word, a URL, a <pre> block or an image inside it sets a minimum size, and the item overflows its container instead of shrinking. Add min-width: 0 to the flex item (or min-height: 0 in a column layout) and it shrinks as you expected.
This is the reason text-overflow: ellipsis sometimes does nothing, a sidebar layout gets a horizontal scrollbar on mobile, or a scrolling panel inside a flex column refuses to scroll. The CSS looks correct in each case. The missing piece is a default you never wrote.
Reproduce it
A common layout: fixed sidebar, flexible main column, and a single line of text that should truncate with an ellipsis.
<div class="row">
<aside class="side">Menu</aside>
<main class="main">
<div class="title">a-very-long-file-name-with-no-spaces-at-all.tar.gz</div>
</main>
</div>
.row { display: flex; width: 300px; }
.side { width: 100px; flex-shrink: 0; }
.main { flex: 1; }
.title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
You expect .main to take the remaining 200px and the title to end in "...". Instead .main grows as wide as the whole string, pushes past the row, and no ellipsis appears. Measured in Chromium with a 200-character string, .main came out around 1,900px wide inside a 300px row.
Now add one line:
.main { flex: 1; min-width: 0; }
.main drops to exactly 200px and the ellipsis shows up.
Why won't a flex item shrink below its content?
Flex items get a special automatic minimum size. In normal block layout, min-width: auto means zero. On a flex item it means something closer to "the smallest this content can be without overflowing", which the spec calls the content-based minimum size: roughly the width of the longest word, the widest image, or the full width of a line that can't wrap.
The flex-shrink property controls how much an item gives up when space is tight, but it can only shrink the item down to its minimum size, never past it. So when the content has a large minimum width, flex: 1 and flex-shrink: 1 have nothing left to work with.
In the example, white-space: nowrap turns the whole title into one unbreakable line. That line becomes the minimum width of .title, which becomes the minimum width of .main. The overflow: hidden on .title doesn't help, because the size is decided one level up, on the flex item.
Things that commonly set a large content minimum:
white-space: nowraptext- long URLs, hashes, file names or tokens with no break points
<pre>and<code>blocks- images, videos and canvases with an intrinsic width
- tables and wide child elements
Setting flex-basis: 0 doesn't fix it either. flex: 1 1 0 changes the starting size, but the minimum still applies, and the item still grows to fit its content.
How do you fix it?
You have three options. They all make the flex item's minimum size zero, in slightly different ways.
| Fix | What it does | Watch out for |
|---|---|---|
min-width: 0 | Replaces auto with an explicit zero minimum | The clearest fix; content can still overflow visibly if nothing clips it |
overflow: hidden (or auto) on the flex item | Scroll containers don't get the automatic minimum, so it becomes 0 | Clips everything inside, including focus rings and dropdowns |
| Ellipsis styles directly on the flex item | Same as above, since it sets overflow: hidden on the item | Only works when the text is the item itself |
min-width: 0 is the one to remember. It says what you mean and doesn't clip anything as a side effect.
The overflow trick works because the automatic minimum only applies to items that are not scroll containers. A scroll container is an element whose overflow is hidden, auto or scroll. That rule also explains why overflow: clip does not fix it: clip cuts off content without creating a scroll container, so the item keeps its content-based minimum. In testing, a flex item with overflow: clip overflowed exactly like the unstyled one. If scroll containers have caught you out before, how overflow-x: auto also creates a vertical scroll container covers the other side of the same rule.
Nested flex containers need it at every level
The fix only applies to the element you put it on. If the text sits inside a flex item that sits inside another flex item, each level has its own automatic minimum.
.main { flex: 1; min-width: 0; display: flex; }
.inner { flex: 1; } /* still min-width: auto */
Here .main correctly shrinks to 200px, but .inner doesn't, so its content overflows .main and spills out of the row. Add min-width: 0 to .inner too. When an ellipsis won't appear in a deep component tree, walk up from the text and check every ancestor that is a flex item.
Why won't my flex column scroll?
The same rule applies to height in a flex-direction: column layout, where the item's minimum is min-height: auto.
.app { display: flex; flex-direction: column; height: 100vh; }
.body { flex: 1; display: flex; flex-direction: column; }
.list { flex: 1; overflow: auto; }
You want .list to fill the space under a header and scroll. Instead, .body grows to the full height of the list, the page scrolls, and .list never does. In a test with a 300px app and a 1,000px list, the list's visible height was the full 1,000px. Adding min-height: 0 to .body brought it down to 250px and the list scrolled on its own.
.list itself is fine, because overflow: auto already makes it a scroll container. The problem is its parent, .body, which is a flex item without any overflow set.
Does CSS grid have the same problem?
Yes. A 1fr grid track has a minimum of auto, so a column with long unbreakable content grows past its share. grid-template-columns: 100px 1fr overflowed a 300px grid in the same way the flex row did.
The fix is to give the track an explicit zero minimum:
.grid { display: grid; grid-template-columns: 100px minmax(0, 1fr); }
minmax(0, 1fr) means "at least 0, at most one fraction of the free space". You can also set min-width: 0 on the grid item itself, but changing the track fixes every item in that column at once.
Key takeaways
- Flex items default to
min-width: auto, which means "no smaller than the content", not zero. flex-shrinkandflex-basis: 0can't shrink an item below that minimum.- Add
min-width: 0(row) ormin-height: 0(column) to the flex item, at every nested level. overflow: hiddenalso works, butoverflow: clipdoes not.- In grid, use
minmax(0, 1fr)instead of1frfor columns with long content.
FAQ
Why does text-overflow: ellipsis not work inside a flex item?
The text element is set up correctly, but its flex item parent grows to fit the full line, so there is never any overflow to truncate. Put min-width: 0 on the flex item that contains the text.
Is min-width: auto a browser bug?
No. It is defined in the CSS Flexible Box Layout spec and all major browsers implement it. It exists so that flex items don't collapse below readable content by default.
Should I add min-width: 0 to every flex item?
Not by default. Most items should keep their content minimum so text doesn't get squeezed or overlap. Add it where an item contains content that is allowed to truncate, wrap or scroll.