Tutorials CSS Flexbox Item Properties
Ch 27 / 60
What you'll learn
Chapter 27 Beginner 9 min read CSS

CSS Flexbox Item Properties

The previous chapter covered all the container properties. This chapter covers the other half — properties applied to individual flex items (the children). These control how each item sizes itself, whether it can grow or shrink, how it overrides the container's alignment, and its visual order.

What you'll learn
flex-grow — distribute free space
flex-shrink — control shrinking
flex-basis — set the starting size
flex shorthand — grow/shrink/basis in one
align-self — override cross-axis alignment
order — change visual order

All Flex Item Properties — Quick Reference

These 6 properties are applied to individual flex items (children of a flex container). They override or extend what the container sets:

flex-grow
default: 0
How much the item grows relative to siblings when there is free space. 0 = don't grow.
flex-shrink
default: 1
How much the item shrinks relative to siblings when there is not enough space. 0 = don't shrink.
flex-basis
default: auto
The item's initial main-axis size before grow/shrink is applied. Like width in a row container.
flex
shorthand
Shorthand for flex-grow + flex-shrink + flex-basis. Most commonly used: flex: 1.
align-self
default: auto
Overrides the container's align-items value for this item only.
order
default: 0
Changes the visual order of the item without changing the HTML. Lower numbers appear first.

flex-grow — Distributing Free Space

flex-grow defines how much an item grows to fill available free space relative to its siblings. The value is a unit-less number — a ratio. 0 (default) means do not grow.

All items: flex-grow: 0 (default) — no growth, free space remains empty
A (grow:0)
B (grow:0)
C (grow:0)
All items: flex-grow: 1 — equal share of all free space
A (grow:1)
B (grow:1)
C (grow:1)
A:grow:1, B:grow:2, C:grow:1 — B gets twice the free space
A (1)
B (2×space)
C (1)
A:grow:0, B:grow:1 (fills all free space), C:grow:0
A (0)
B fills all free space
C (0)
CSS — flex-grow
/* flex-grow: <number> — default 0 */
.item-a { flex-grow: 0; }  /* don't grow (default) */
.item-b { flex-grow: 1; }  /* grow to fill free space */
.item-c { flex-grow: 2; }  /* grows twice as much as item-b */

/* How it works:
   Total grow units = sum of all flex-grow values
   Each item gets: (its grow / total) × free space

   Example: A=1, B=2, C=1 → total=4
   Free space = 120px
   A gets: 1/4 × 120 = 30px extra
   B gets: 2/4 × 120 = 60px extra
   C gets: 1/4 × 120 = 30px extra */

/* Common pattern: fill remaining space */
.nav         { display: flex; }
.nav .spacer { flex-grow: 1; } /* push items to edges */

flex-shrink — Controlling Shrinkage

flex-shrink defines how much an item shrinks relative to its siblings when there is not enough space. Default is 1 (items shrink proportionally). 0 means never shrink — the item will overflow before shrinking.

flex-shrink: 1 (default) — all items shrink equally
A shrink:1
B shrink:1
C shrink:1

Each item shrinks the same amount to fit container

B has flex-shrink: 2 — B shrinks twice as much
A shrink:1
B shrink:2
C shrink:1

B shrinks more than A and C

flex-shrink: 0 — item NEVER shrinks
A shrink:1
B shrink:0
C shrink:1

B keeps its width, A and C absorb all shrinkage

Real use: sidebar with fixed width
sidebar
shrink:0
main content
grows & shrinks

Sidebar stays 80px, main content is flexible

CSS — flex-shrink
/* flex-shrink: <number> — default 1 */
.item        { flex-shrink: 1; }   /* shrinks (default) */
.no-shrink   { flex-shrink: 0; }   /* never shrinks */
.more-shrink { flex-shrink: 3; }   /* shrinks 3× as much */

/* Common patterns */

/* Avatar + text row — avatar stays fixed */
.avatar { flex-shrink: 0; width: 48px; }
.text   { flex-shrink: 1; min-width: 0; }

/* Fixed sidebar layout */
.sidebar { flex-shrink: 0; width: 260px; }
.main    { flex-shrink: 1; min-width: 0; }

/* ⚠ Always add min-width:0 on shrinking text items
   to allow text-overflow:ellipsis to work correctly */

flex-basis — Setting the Starting Size

flex-basis sets the item's initial main-axis size before any growing or shrinking happens. In a row container it acts like width. In a column container it acts like height.

flex-basis: auto (default)
Short
Much longer text item
Med text

Items size to their content

flex-basis: 0
Short
Much longer text item
Med text

All start at 0, grow equally → equal widths

flex-basis: 120px (fixed start)
A: 120px
B: 120px
C: 120px

Each starts at 120px

flex-basis: 33% (percentage)
A: 33%
B: 33%
C: 33%

Three equal columns

CSS — flex-basis
/* flex-basis: <length> | percentage | auto | 0 | content */

.item { flex-basis: auto; }      /* default — size to content */
.item { flex-basis: 0; }         /* start at zero (used with flex-grow) */
.item { flex-basis: 200px; }    /* fixed starting width */
.item { flex-basis: 33.33%; }  /* percentage of container */
.item { flex-basis: content; }  /* size to content (like auto) */

/* flex-basis vs width:
   - In a row container: flex-basis sets the initial WIDTH
   - flex-basis takes precedence over width when both are set
   - In a column container: flex-basis sets initial HEIGHT */

/* auto vs 0:
   auto → item starts at its content size, then grows/shrinks
   0    → item starts at zero, then grows proportionally
   0 with flex-grow:1 = perfectly equal columns */

flex — The Shorthand You'll Use Most

The flex property is a shorthand for flex-grow, flex-shrink, and flex-basis in that order. In practice, you will almost always use one of these preset values rather than setting all three separately:

flex: 1
→ flex: 1 1 0
Grow, shrink, start at 0. Equal columns that fill all space. Most common value.
flex: auto
→ flex: 1 1 auto
Grow, shrink, start at content size. Items grow/shrink proportionally from their natural sizes.
flex: none
→ flex: 0 0 auto
Don't grow, don't shrink. Item is exactly its content size. Rigid — no flexibility.
flex: 0
→ flex: 0 1 0
Don't grow, can shrink, start at 0. Item collapses to zero unless content forces a minimum.
flex: 2
→ flex: 2 1 0
Grows twice as much as siblings with flex:1. Used for proportional sizing.
flex: 1 1 200px
→ explicit all three
Starts at 200px, can grow and shrink. Common in responsive card grids.
flex:1 on all items — equal columns regardless of content length
Short
A much longer title here
Medium item
flex:none on all items — each item is its content size only
Short
A much longer title here
Medium item
CSS — flex shorthand
/* flex: <grow> <shrink> <basis> */
.item { flex: 1; }          /* grow:1 shrink:1 basis:0  ← most used */
.item { flex: auto; }       /* grow:1 shrink:1 basis:auto */
.item { flex: none; }       /* grow:0 shrink:0 basis:auto (rigid) */
.item { flex: 0 0 200px; }  /* fixed 200px, won't grow or shrink */
.item { flex: 1 1 250px; }  /* min 250px, grows and shrinks */
.item { flex: 2; }          /* gets 2× free space vs flex:1 siblings */

/* ── Practical patterns ── */

/* Equal columns */
.col { flex: 1; }

/* Sidebar + main layout */
.sidebar { flex: 0 0 260px; } /* fixed sidebar */
.main    { flex: 1; }          /* main fills rest */

/* Responsive cards */
.card { flex: 1 1 300px; max-width: 400px; }

/* Avatar in a row — avatar stays fixed */
.avatar  { flex: none; width: 48px; }
.content { flex: 1; min-width: 0; }
Value Expands to Effect Use when
flex: 1 1 1 0 Equal columns, fills all space Equal-width layout columns
flex: auto 1 1 auto Grow/shrink from content size Nav links with equal spacing
flex: none 0 0 auto Stays at content size always Fixed elements (avatars, icons)
flex: 0 0 Npx explicit Fixed Npx, no flexibility Sidebar with exact width
flex: 1 1 Npx explicit Min Npx, grow and shrink Responsive cards with min-width
flex: N N 1 0 N× more free space than flex:1 Proportional columns (2:1:1)

align-self — Override Cross-Axis Alignment

align-self overrides the container's align-items value for a single specific item. The container sets the default alignment for all items — align-self lets one item be different. All other items align as normal:

CSS — align-self
.container {
  display:     flex;
  align-items: center;   /* default for all items */
}

.item-a { }                          /* inherits center */
.item-b { align-self: flex-start; } /* overrides — goes to top */
.item-c { align-self: flex-end; }   /* goes to bottom */
.item-d { align-self: stretch; }    /* fills cross axis height */
.item-e { align-self: baseline; }   /* aligns by text baseline */
.item-f { align-self: auto; }       /* default — inherits container */

/* Real use: pull one card to bottom of a row */
.card-row   { display: flex; align-items: flex-start; }
.cta-button { align-self: flex-end; margin-top: auto; }

order — Changing Visual Order

The order property changes the visual order of flex items without modifying the HTML. Items with lower order values appear first. Default is 0 — all items appear in DOM order.

Default order: 0 for all items — follows DOM order
DOM 1st
order:0
DOM 2nd
order:0
DOM 3rd
order:0
DOM 4th
order:0
With order values — visual order changes, DOM is unchanged
DOM 1st
order:3 → last
DOM 2nd
order:1 → 1st
DOM 3rd
order:4 → last
DOM 4th
order:2 → 2nd

Orange(order:1) → Green-purple(order:2,3) → Blue(order:3) → Green(order:4)

Negative order: moves item before order:0 items
DOM 1st
order:0
DOM 2nd
order:0
DOM 3rd — first!
order:-1
DOM 4th
order:0
CSS — order
/* order: <integer> — default 0 */
.item-a { order: 0; }   /* default */
.item-b { order: -1; }  /* appears first (before 0) */
.item-c { order: 1; }   /* appears after 0 items */
.item-d { order: 2; }   /* appears last */

/* Real use: reverse column for mobile
   sidebar appears below content on small screens */
@media (max-width: 640px) {
  .container { flex-direction: column; }
  .sidebar   { order: 2; }   /* after main content */
  .main      { order: 1; }   /* main content first */
}

/* ⚠ Accessibility warning:
   order changes visual order but NOT tab order (keyboard navigation)
   and NOT reading order for screen readers. Tab/read order
   still follows DOM order. Use only when visual reorder is
   cosmetic — not for content that changes meaning by order. */
Accessibility note for order
The order property only changes the visual order. Keyboard navigation (Tab key) and screen readers still follow the DOM order. This creates a mismatch that can confuse keyboard and assistive technology users. Only use order for cosmetic reordering — for example pushing a decorative element to the end. Never use it for content where reading order matters.
Free Resource
CSS3 Cheat Sheet — All Properties & Selectors
Complete reference covering all Flexbox container and item properties with visual examples.
Download PDF

Try It Yourself

Experiment with flex item properties. Try changing flex-grow ratios, setting flex-shrink:0 on individual items, using different flex shorthand values and reordering with order:

Live Editor
✎ Editor
👁 Preview
Featured Course — Enroll Now
Modern Web Development With AI
Master HTML, CSS, JavaScript, React and Node.js with real projects and placement support.
120+
Chapters
40 hrs
Content
10 Real
Projects
4.9 ⭐
Rating
HTML5CSS3JavaScriptReact.jsNode.jsTailwind CSSAI Tools

Quick Check — Chapter 27

Questions & Answers
They are opposites — one handles extra space, the other handles insufficient space:

flex-grow — controls how items expand to fill available free space when the container is larger than the combined size of all items. Default is 0 — items don't grow. When set to a positive number, items take a proportional share of the leftover space. If A=1 and B=2, B gets twice as much of the free space as A.

flex-shrink — controls how items shrink when the container is smaller than the combined size of all items. Default is 1 — items shrink proportionally. 0 means the item will never shrink — it will overflow before shrinking. Higher values mean the item absorbs more of the overflow by shrinking more.

They work in opposite scenarios: grow handles abundance of space, shrink handles shortage of space.
flex: 1 expands to flex-grow: 1; flex-shrink: 1; flex-basis: 0.

It's commonly used because it creates perfectly equal-width columns that fill all available space:

— flex-basis: 0 means all items start at zero width (ignoring their content size)
— flex-grow: 1 means all items grow equally from that zero baseline
— The result: regardless of content length, all items end up exactly the same width

This is different from flex: auto (= 1 1 auto) where items start at their content size before distributing leftover space — so items with longer content end up wider.

Use flex: 1 when you want truly equal columns. Use flex: auto when you want items to be proportional to their content.
flex-basis: auto — the item starts at its natural content size (or its set width/height). Flex grow/shrink then distributes the leftover space after content sizes are accounted for. Items with more content naturally take up more space.

flex-basis: 0 — the item starts at zero width (ignoring content). Flex grow then distributes all the available space from scratch. When combined with equal flex-grow values, all items end up exactly equal width regardless of their content size.

Example: Three items with content "A", "A long title", "B".
— With flex: auto (= auto basis): widths are proportional — "A long title" takes more space.
— With flex: 1 (= basis 0): all three items are exactly equal width.
align-items is a container property — it sets the cross-axis alignment for all items in the container simultaneously.

align-self is an item property — it overrides the container's align-items value for one specific item. All other items continue to follow the container's align-items value.

Use case: a row of cards where all cards align to the top (align-items: flex-start), but one special "featured" card should stretch to full height (align-self: stretch) or a CTA button pushed to the bottom (align-self: flex-end).

Possible values: same as align-items — auto (inherits, default), stretch, flex-start, flex-end, center, baseline.
order changes the visual order of flex items without modifying the HTML structure. Items with lower order values appear first. The default is 0 for all items (DOM order). Negative values move items before everything with order 0.

Accessibility limitation: The order property only changes visual order. The keyboard Tab navigation order and screen reader reading order still follow the DOM order (the HTML source order). This creates a disconnect — sighted users see one order, but keyboard users and screen reader users experience a different order.

This mismatch violates WCAG 1.3.2 (Meaningful Sequence) and 2.4.3 (Focus Order). As a result, order should only be used for purely cosmetic reordering where the sequence doesn't affect meaning — for example, pushing a decorative icon to the end of a row. Never use it for content where the reading or interaction sequence matters.
Multiple Choice Questions
Question 1 of 5
Three items have flex-grow: 1, flex-grow: 2, flex-grow: 1. There is 120px of free space. How much extra space does the second item receive?
Question 2 of 5
What does flex-shrink: 0 do to an item?
Question 3 of 5
What does flex: none expand to?
Question 4 of 5
The container has align-items: flex-start. One item has align-self: center. What happens?
Question 5 of 5
An item has order: -1. What happens?
Chapter Summary
  • flex-grow (default: 0) — how much an item expands to fill free space. 0 = don't grow. Values are ratios: grow:2 gets twice as much as grow:1.
  • flex-shrink (default: 1) — how much an item shrinks when space is tight. 0 = never shrink. Always add min-width: 0 on shrinking text items for truncation to work.
  • flex-basis (default: auto) — initial main-axis size. auto = content size. 0 = start at zero (equal columns when combined with grow:1). Takes precedence over width.
  • flex shorthand: flex: 1 = (1 1 0) equal columns. flex: auto = (1 1 auto) proportional. flex: none = (0 0 auto) rigid. flex: 0 0 200px = fixed 200px.
  • align-self — overrides the container's align-items for one specific item. Values: auto (default), stretch, flex-start, flex-end, center, baseline.
  • order (default: 0) — changes visual order. Lower numbers first. Negative values appear before 0. Accessibility warning: DOM order (tab/read order) is unchanged.
  • Sidebar layout: sidebar { flex: 0 0 260px; } + main { flex: 1; min-width: 0; }
  • Equal columns: flex: 1 on all items.
~9 min read
Beginner level
Chapter 27 of 60

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel