Home CSS Properties flex-shrink CSS flex-shrink Property Definition
Definition and Usage The flex-shrink property sets a flex item’s shrink factor — how much it should give up main-axis size when items are too wide (or tall) for the container.
The initial value is 1 (items may shrink). Use 0 to refuse shrinking. It applies only to flex items inside a display: flex container. It is not inherited. MDN recommends the flex shorthand for everyday grow + shrink + basis patterns.
Baseline widely available. Not deprecated. Prefer non-negative numbers. Negatives are invalid. Shrinking is weighted by base size so tiny items are less likely to collapse to zero before larger ones shrink.
Syntax
CSS Syntax flex-shrink: <number> | initial | inherit ;
One non-negative number. Examples: 0, 1, 2, 0.5.
Values
Property Values Value Description Try it 0Do not shrink. Keeps the item’s base size Try it1May shrink. Initial value; equal share when siblings also use 1 Try it2Gives up more of the shortage than an item with 1 Try it<number>Any non-negative number used as a shrink ratio Try itinitialResets to 1 Try itinheritInherits from the parent element Try it
Approach
How to Use flex-shrink Create overflow pressure on the main axis, then decide which items give way.
Set the parent to display: flex with a limited width (or height). Give items a large flex-basis or width so they want more space than the container has. Set flex-shrink on items that should compress (1 is default; 0 locks size). Pair with flex-grow or use the flex shorthand for complete control. Piece Required? Role Flex container Yes Parent must be display: flex or inline-flex Negative free space Yes (to see shrinking) Items’ base sizes larger than the container Shrink factor Yes Ratio for how much each item gives up flex-basis / width Matters Starting size before shrink is applied
Try it
Live Preview A narrow row holds three wide items. Only item A’s flex-shrink changes.
Code
CSS Examples Each snippet focuses on flex-shrink. A fixed container width creates the squeeze. Use Try It Yourself for a live editor.
1. Default 1 2. Lock with 0 3. Ratio Example 1 — Default Shrink With flex-shrink: 1, wide items compress to fit the row.
<style>
.row {
display: flex;
width: 280px;
}
.item {
flex-basis: 150px;
flex-shrink: 1;
}
</style>
<div class="row">
<div class="item">A</div>
<div class="item">B</div>
</div> How It Works Limit the row. width: 280px is smaller than two 150px bases.Set a large basis. Each item wants 150px before shrinking.Allow shrink. flex-shrink: 1 (the default) lets both items share the shortage.No overflow. The row stays within 280px because items give up space.Example 2 — Refuse to Shrink Lock one item with flex-shrink: 0 so others take the squeeze.
<style>
.row {
display: flex;
width: 280px;
}
.a {
flex-basis: 150px;
flex-shrink: 0;
}
.b {
flex-basis: 150px;
flex-shrink: 1;
}
</style>
<div class="row">
<div class="a">A (0)</div>
<div class="b">B (1)</div>
</div> How It Works Same tight row. Two 150px bases still exceed 280px.Lock A. flex-shrink: 0 keeps A near its basis.B absorbs more. With shrink 1, B gives up most of the shortage.Common use. Icons or labels often use 0 so text fields shrink instead.Example 3 — Unequal Shrink A higher factor makes that item give up more of the shortage.
<style>
.row {
display: flex;
width: 280px;
}
.a {
flex-basis: 150px;
flex-shrink: 1;
}
.b {
flex-basis: 150px;
flex-shrink: 2;
}
</style>
<div class="row">
<div class="a">A (1)</div>
<div class="b">B (2)</div>
</div> How It Works Create a shortage. Bases still exceed the 280px row.Compare factors. B at 2 gives up more of the negative space than A at 1.Base size still matters. Shrink is weighted so large items do not ignore tiny ones completely.Opposite of grow. flex-grow shares leftover space; shrink shares a shortage. Edge Cases & Pitfalls If items never shrink (or always overflow), check these points.
parent Needs a flex container flex-shrink only applies to flex items. Set display: flex on the parent first.
space No shortage, no shrink If items already fit, shrink factors do nothing visible. Use a smaller container or larger flex-basis to study the effect.
min min-width can block shrinking Default min-width: auto can stop an item from getting smaller than its content. Use min-width: 0 when text should compress inside flex layouts.
minus Negatives are invalid flex-shrink: -1 is dropped. Use 0 or a positive number.
grow Shrink is not grow When there is leftover space, flex-grow applies. When there is a shortage, flex-shrink applies.
Compatibility
Browser Support flex-shrink is a browser CSS property for Flexbox. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
flex-shrink Supported in all modern browsers as part of CSS Flexible Box Layout (Baseline since September 2015).
100% Non-negative numbers
Google Chrome 29+
Full support
Mozilla Firefox 20+
Full support
Apple Safari 9+
Full support
Microsoft Edge 12+
Full support
Opera 17+
Full support
Samsung Internet All versions
Full support
Internet Explorer 11
Full support flex-shrink Widely supported
Bottom line: Safe for production Flexbox layouts. Prefer the flex shorthand for common patterns. It is not a runtime API.
Remember
Key Takeaways Role: decide how flex items share a shortage of main-axis space.
Initial value: 1. Not inherited.
Lock size: flex-shrink: 0 prevents shrinking.
Tip: use the flex shorthand when you also set grow and basis.
One line: flex-shrink is the ratio for giving up space when flex items are too big — 0 refuses, 1 shares the squeeze.
Frequently Asked Questions What does the CSS flex-shrink property do? It sets how much a flex item should shrink relative to its siblings when their base sizes are too large for the flex container.
What is the default value of flex-shrink? The initial value is 1, so flex items can shrink by default when space is tight.
How do I stop an item from shrinking? Set flex-shrink: 0. That item keeps its base size and other items (or overflow) absorb the squeeze.
Is flex-shrink: 2 twice as small as flex-shrink: 1? It gives up about twice as much of the negative free space as an item with 1, weighted by base size — not simply half the final width.
Should I use the flex shorthand instead? MDN recommends flex for common patterns because it also sets flex-grow and flex-basis. Use flex-shrink alone when you need precise control.
Which browsers support flex-shrink? It is Baseline and widely available in modern browsers. It is a browser CSS property, not a Node.js feature.
Next: flex-wrap Learn how flex items can wrap onto new lines when space runs out.
flex-wrap tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion