Note #06 ·
Flex item overflow: when min-width: 0 fixes the row
A flex item starts with min-width: auto , and on flex and grid items that keyword resolves to a content-based minimum instead of zero. One unbreakable token, such as a filename or a hash with no spaces in it, then sets a floor that shrinking cannot pass. The item stays wider than its share of the row and the text runs past the container edge. Setting min-width: 0 on the flexible item removes that floor.
Row 1: min-width: auto. The token sets the minimum, so the item overflows the dashed flex container and pushes the last tag out of view.
Row 2: min-width: 0 with overflow-wrap: anywhere. Same token, fully readable, and the row stays inside its frame.
Row 3: min-width: 0 with one line and text-overflow: ellipsis. Tab to the link: the focus ring is painted inside the clipped box, and the full name stays in the title attribute.
A flex item starts with min-width: auto, and on flex and grid items that keyword resolves to a content-based minimum instead of zero. One unbreakable token, such as a filename or a hash with no spaces in it, then sets a floor that shrinking cannot pass. The item stays wider than its share of the row and the text runs past the container edge. Setting min-width: 0 on the flexible item removes that floor.
Why the automatic minimum beats flex-shrink
The initial value of min-width is auto, and the box type decides what that keyword means. On block boxes, inline boxes, inline blocks and table layout boxes it resolves to 0. On flex items and grid items it uses the specified suggested size, such as the value of width; a transferred size when an aspect-ratio meets a definite height; and otherwise the min-content size.
A string with no spaces or hyphens offers no break opportunities, so its min-content width is the width of the whole token. That becomes the item's minimum. The shrink factor reduces everything it is allowed to reduce, stops at the minimum, and the remaining text keeps going past the flex container. The floor is behaving as specified, which is why the bug looks so stubborn.
One documented exception explains a common surprise: a flex item that is a scroll container has an automatic minimum size of 0. Adding overflow: hidden or overflow: auto can therefore repair the row without touching min-width at all.
Zero is only one of the available floors, and the intrinsic keywords are useful when you want a deliberate limit rather than none:
| Value | What it sets as the minimum |
|---|---|
auto | Content-based on flex and grid items; 0 on block, inline, inline-block and table boxes. |
0 or a length | A fixed floor. Zero lets the item shrink as far as the row needs. |
min-content | The intrinsic minimum width. |
max-content | The intrinsic preferred width. |
fit-content | min(max-content, max(min-content, stretch)), so available space is used up to the preferred width. |
Three rows, one long token
The demo above is an editorial example that repeats the same markup three times: a fixed tag, a flexible item holding a link with a long release filename, and a second fixed tag. The dashed border marks the flex container so you can see where the row is meant to end. Each frame scrolls horizontally, which keeps the broken row inside the demo instead of stretching the page.
Row 1 leaves min-width: auto in place. The filename sets the minimum, the item overflows the dashed box, and the trailing tag is pushed out of view. Row 2 changes one declaration and adds wrapping. Row 3 keeps a single line and clips it. The rules behind all three are short:
.wc-flex-row { display: flex; align-items: center;
gap: .5rem; }
.wc-flex-tag { flex: none; }
.wc-flex-item { flex: 1 1 auto; } /*
min-width: auto by default */
.wc-flex-item-zero { min-width: 0; } /* floor
removed */
.wc-flex-wrap { overflow-wrap: anywhere; }<div class="wc-flex-row">
<span class="wc-flex-tag">
build
</span>
<div class="wc-flex-item wc-flex-item-zero
wc-flex-wrap">
<a
href="/elements/long-word-that-will-not-bend/">
release-8f3c1d9e4b7a2f605c1d8e93-preview.tar.gz
</a>
</div>
<span class="wc-flex-tag">
archive
</span>
</div>Wrapping the token with overflow-wrap: anywhere
overflow-wrap applies to text and decides whether the browser may break an otherwise unbreakable string to stop it overflowing its line box. With anywhere, a long word or URL may break at any point when the line has no acceptable break opportunity, and no hyphenation character is inserted. Unlike word-break, it only steps in when the whole word cannot sit on a line of its own.
The gap between anywhere and break-word is exactly what this flex row exposes. Both permit arbitrary breaks, but only anywhere counts the soft wrap opportunities it introduces when min-content intrinsic sizes are calculated. So anywhere can lower a flex item's automatic minimum on its own, while break-word leaves the floor at the full token width and needs min-width: 0 beside it. Any box sized by min-content shows the same asymmetry.
A naming note for older stylesheets: the property began as a nonstandard Microsoft extension called word-wrap, which most browsers implemented under that name. It was later renamed to overflow-wrap, and word-wrap survives as an alias.
An ellipsis is a different decision
Wrapping keeps every character on screen. Truncation removes characters from view, so it needs a reason. In the demo, row 3 uses the familiar three declarations on the anchor, and they only work because min-width: 0 has already constrained the box:
.wc-flex-clip .wc-flex-link {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}Truncation suits secondary metadata where the complete value stays reachable, for example in a title attribute, an expandable row or a detail page. It suits nobody who has to read, compare or retype an identifier, because the part of a hash or filename worth reading is often the tail that vanishes.
Clipping also affects keyboard use. overflow: hidden cuts an outline painted outside the box, so row 3 puts the ellipsis on the anchor itself and gives that anchor a negative outline-offset, which paints the focus ring inside the clipped area. Tab through the three rows and each link keeps a visible ring. The full filename also stays in the markup and in the title attribute, so the characters hidden on screen are still available elsewhere.
A checklist for rows that still overflow
Work from the constrained box inwards. Every flex item between that box and the text needs its own min-width: 0, so a toolbar inside a card inside a sidebar can need the declaration three times before the innermost paragraph is allowed to shrink. Fixing only the inner element leaves an ancestor holding the row open.
Remember too that min-width: 0 adds no break opportunities. Under overflow-wrap: normal the token still refuses to break, and the overflow moves from the row into the item, where it can overlap neighbouring content. Decide the behaviour you want: wrapping when the text should stay readable, a scroll container when it should stay on one line and remain reachable.
Grid items follow the same automatic-minimum rule, so the same fix applies there. Grid has an extra case worth knowing: a grid item that spans more than one flexible column track gets an automatic minimum of 0, which is why a spanning cell can behave differently from its single-track neighbour holding identical text.
Questions and answers
Is min-width: 0 just another way of writing a shrink factor?
No. min-width sets a floor under the used width, and shrinking stops at that floor. Setting min-width: 0 lowers the floor so the item can shrink further; the flex grow and shrink factors themselves are unchanged.
Why did overflow: hidden fix the row without min-width: 0?
Because a flex item that is a scroll container has an automatic minimum size of 0. Adding overflow: hidden or overflow: auto makes the item a scroll container and removes the content-based floor as a side effect. The text is then clipped or scrollable rather than wrapped.
Does overflow-wrap: break-word do the same job as anywhere?
Both break an unbreakable string when the line has no acceptable break point, but only anywhere counts those break opportunities when min-content intrinsic sizes are calculated. On a flex item with min-width: auto, break-word leaves the minimum at the full token width, so pair it with min-width: 0.
Sources
Checked 1 December 2026.