# CSS Grid Track Sizing Algorithm vs Flexbox & Intrinsic Sizing

- **Canonical URL:** https://frontend.rocks/vs/css-grid-track-sizing-vs-flexbox-intrinsic-sizing/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** Grid sizes 2D tracks before placing items, whereas Flexbox distributes 1D space from item intrinsic sizes.

## Comparison Matrix

| Dimension | CSS Grid Track Sizing Algorithm | Flexbox & Intrinsic Sizing |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Widely |
| **Domain** | CSS & Layout | CSS & Layout |
| **Mental Model** | Grid resolves tracks in four passes: fixed lengths, intrinsic content bounds, minmax() clamping, and fr free-space distribution. | Flex items default to min-width: auto, preventing shrink below their min-content size unless min-width: 0 or overflow is set. |
| **Prerequisites** | Block Formatting Context (BFC) (Grid establishes a grid formatting context independent of block and float flow.) | Block Formatting Context (BFC) (Flexbox replaces block flow with main/cross axis sizing inside a flex formatting context.) |
| **When Not to Use** | When not to use Grid: Avoid Grid for simple inline wrapping chips or toolbars where items should size to their own content and wrap naturally, use Flexbox with flex-wrap: wrap. | When not to use Flexbox: Avoid Flexbox for strict two-dimensional card alignments where row tracks must line up across columns; use CSS Grid instead. |

## CSS Grid Track Sizing Algorithm — Under the Hood
Grid sizing works like dividing a restaurant bill: fixed-price items come off the top, minimum cover charges (`min-content`) are reserved, and `fr` tracks split whatever cash remains on the table.

1. **Fixed Pass**: Explicit `px`, `rem`, and resolved `%` tracks lock immediately.
2. **Intrinsic Pass**: `auto`, `min-content`, and `1fr` tracks query their children's minimum content widths, just like [Flexbox & Intrinsic Sizing](/concepts/flexbox-intrinsic-sizing).
3. **Flexible (`fr`) Pass**: Leftover space divides proportionally across `fr` factors; `minmax(0, 1fr)` bypasses the intrinsic minimum floor.

```css
.app-shell {
  display: grid;
  /* Prevents wide <pre> blocks from blowing out the main column */
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.5rem;
}
```

To share parent tracks with nested card internals, pair this with [CSS Subgrid](/concepts/css-subgrid).

## Flexbox & Intrinsic Sizing — Under the Hood
Flexbox runs a two-pass negotiation: first it measures every child's intrinsic content size, then it distributes surplus or deficit space along the main axis.

1. **Hypothetical Base Size**: The engine resolves `flex-basis` (falling back to `width`/`height`, then `max-content`).
2. **The `min-width: auto` Clamp**: Unless the item is a scroll container, its minimum main size defaults to its `min-content` width, blocking `flex-shrink: 1` from crushing text or images.
3. **Space Distribution**: Free space is allocated proportionally by `flex-grow` or subtracted by `flex-shrink * flex-basis`.

```css
/* Without min-width: 0, long tokens push the flex row off-screen */
.sidebar-label {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
```

Compare this single-axis negotiation with [CSS Grid Track Sizing](/concepts/css-grid-track-sizing), where tracks also clamp at `minmax(auto, 1fr)` unless written as `minmax(0, 1fr)`, and [Block Formatting Context](/concepts/block-formatting-context) flow.

## Interactive Labs & Dissections
- [CSS Grid Track Sizing Algorithm Lab](https://frontend.rocks/concepts/css-grid-track-sizing/#lab) ([Markdown](https://frontend.rocks/concepts/css-grid-track-sizing.md))
- [Flexbox & Intrinsic Sizing Lab](https://frontend.rocks/concepts/flexbox-intrinsic-sizing/#lab) ([Markdown](https://frontend.rocks/concepts/flexbox-intrinsic-sizing.md))

## Primary Sources
- https://drafts.csswg.org/css-grid-2/#algo-track-sizing
- https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout
- https://drafts.csswg.org/css-flexbox-1/#min-size-auto
- https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout
