CSS flex items are the direct children of a flex container. Flex item properties control
how each item grows, shrinks, starts its size, aligns itself, and changes visual order
inside a Flexbox layout.
What Are CSS Flex Items?
A flex item is any direct child of an element with display: flex; or
display: inline-flex;. The parent is called the flex container, and the
children are called flex items.
In this example, each .flex-item becomes part of the Flexbox layout.
Why Flex Items Are Important
They control how individual elements grow and shrink.
They help create equal-width or flexible-width layouts.
They support responsive card rows and form layouts.
They allow one item to align differently from others.
They can change visual order inside a flex container.
They help build modern UI components without float hacks.
CSS Flex Items Cheatsheet
The following table explains the most important CSS properties used on flex items.
Property
Example
Purpose
flex-grow
flex-grow: 1;
Controls how much an item grows when extra space is available.
flex-shrink
flex-shrink: 0;
Controls how much an item shrinks when space is limited.
flex-basis
flex-basis: 250px;
Sets the starting size before growing or shrinking.
flex
flex: 1 1 250px;
Shorthand for grow, shrink, and basis.
align-self
align-self: flex-start;
Overrides cross-axis alignment for one item.
order
order: 2;
Changes the visual order of a flex item.
margin-inline-start
margin-inline-start: auto;
Pushes an item away from previous items in logical inline direction.
min-width
min-width: 0;
Allows long content to shrink properly inside flex layouts.
max-width
max-width: 320px;
Limits item width in flexible layouts.
Only Direct Children Become Flex Items
Flex item properties apply to direct children of the flex container. Nested elements
are not flex items unless their own parent also becomes a flex container.
In this example, .nav-actions moves to the far end of the navigation bar.
min-width: 0 in Flex Items
Long text inside flex items can overflow because flex items often have an automatic
minimum size. Setting min-width: 0; allows text to shrink and wrap properly.
Forgetting that flex item properties only apply to direct children.
Using flex-grow without understanding available space.
Using flex-shrink: 0; too much and causing overflow.
Forgetting min-width: 0; when text truncation does not work.
Using fixed widths when flex-basis would be more flexible.
Expecting align-self to affect main-axis alignment.
Not testing flex item wrapping on small screens.
CSS Flex Item Best Practices
Use flex: 1; for equal-width items.
Use flex: 1 1 260px; for responsive cards.
Use flex: 0 0 auto; for icons, buttons, and fixed-size controls.
Use min-width: 0; when long text must shrink or truncate.
Use align-self only when one item needs special cross-axis alignment.
Use auto margins for pushing items in navbars or toolbars.
Use order sparingly and keep source order logical.
Prefer flexible sizing over fixed widths for responsive layouts.
Test flex item behavior on mobile, tablet, desktop, and zoomed text.
Key Takeaways
Flex items are direct children of a flex container.
flex-grow controls how items grow.
flex-shrink controls how items shrink.
flex-basis sets the starting size.
flex is shorthand for grow, shrink, and basis.
align-self overrides cross-axis alignment for one item.
order changes visual order but not HTML source order.
min-width: 0; is often needed for text truncation in flex layouts.
Pro Tip
For responsive cards, use flex: 1 1 260px;. For fixed icons or avatars,
use flex: 0 0 auto;. For long text inside flex rows, add
min-width: 0; to the flexible content area.
You now understand CSS flex items, direct children, flex-grow, flex-shrink,
flex-basis, flex shorthand, align-self, order, auto margins, min-width fixes,
responsive item layouts, accessibility, SEO benefits, best practices,
and common mistakes.