CSS flex Property Explained
What the CSS flex property does, with an example.
Published November 3, 2026
The flex shorthand sets how a flex item grows, shrinks and what its starting size is: flex: <grow> <shrink> <basis>. flex: 1 makes items share space equally.
How it works
flex-grow distributes extra space, flex-shrink controls shrinking when space is short and flex-basis is the initial size before growing or shrinking.
flex: 1 equals 1 1 0%; flex: none equals 0 0 auto.
Values and effects
flex: 1; → grow equally, basis 0
flex: 0 0 200px; → fixed 200px
flex: auto; → size by content, can grow/shrink
flex: none; → do not flex
Practical examples
Equal columns
.col { flex: 1; }Fixed sidebar + fluid main
.side { flex: 0 0 240px; }
.main { flex: 1; min-width: 0; }Don't shrink an icon
.icon { flex-shrink: 0; }Common mistakes
- Forgetting min-width: 0 so long content overflows.
- Confusing flex-basis with width.
- Using flex on elements whose parent is not a flex container.
Key takeaways
- flex in one line: The flex shorthand sets how a flex item grows, shrinks and what its starting size is: flex: <grow> <shrink> <basis>.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
What does flex: 1 do?
The item grows to fill available space equally with other flex: 1 items.
Is flex supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.