flex-basis
Widely availableSince 201597% of users
Defines the initial size of a flex item before the container distributes any remaining space. It works like width or height depending on the flex-direction.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyClassic, with newer partsIt has worked everywhere since September 2015, and it keeps getting newer values.
Newer parts of flex-basis
fit-contentBaseline Sept 2022, Widely Mar 2025max-contentBaseline Sept 2022, Widely Mar 2025min-contentBaseline Sept 2022, Widely Mar 2025contentBaseline Mar 2022, Widely Sept 2024
See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
auto- Inherited
- No
- Applies to
- Flex items and in-flow pseudo-elements
- Animation type
- length, percentage, or calc()
Quick example
.flex-item {
flex-basis: 300px;
flex-grow: 1;
} /* starts at 300px, then grows to fill space */Syntax
flex-basis: content | <length-percentage> | autoauto- Default. Uses the item's width (or height in column containers) if set, otherwise falls back to content size.
<length>- Fixed size like 200px or 10rem. The item starts at that size before flex-grow and flex-shrink apply.
<percentage>- Percentage of the flex container's main size.
0- Base size is zero. Useful when you want flex-grow to distribute space without content size interfering.
content- Sizes to the content of the item, ignoring any declared width or height.
Examples
Equal columns that ignore content size
.columns > * {
flex-basis: 0;
flex-grow: 1;
}Start every item at size 0, then let flex-grow distribute space equally. All columns end up the same width regardless of their content.
Fixed starting size with room to grow
.card {
flex-basis: 240px;
flex-grow: 1;
}Card starts at 240px. If the container has extra space, the card grows. If there is not enough space, multiple cards in a row can wrap.
Size to content explicitly
.tag {
flex-basis: content;
}Forces the item to size based on its content even if width is set. Less common, but useful for overriding inherited widths.
Common pitfalls
- auto is not the same as 0With flex-basis: auto (the default), flex-grow distributes only what is left after each item's natural size. With flex-basis: 0, all space is up for grabs, so flex-grow ratios produce true equal or proportional widths. Use 0 for predictable layouts.
- flex: 1 changes flex-basis to 0The shorthand flex: 1 expands to flex: 1 1 0%. Writing flex-grow: 1 on its own keeps flex-basis at auto, which gives different space distribution. Reach for flex: 1 when you want equal share behavior.
- width can override flex-basisWhen flex-basis is auto, the item falls back to its width (or height). If you set both flex-basis and width, flex-basis wins on the main axis, but this confuses many developers. Set one or the other, not both.
See also
flex-basis browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
29+
22+
9+
12+Mobile
29+Android
22+Android
9+iOS