liveBook · Manning

Min-content

As explained in Math for Web Design

Minimum content width is the smallest width required by an item's content under CSS intrinsic sizing rules.

min-content is the smallest width a grid track can take without overflowing its content. For a column, it is usually the width of the widest unbreakable word, though a fixed-size element can also determine it. section 4.4.2

The value matters when flexible space disappears. If fixed tracks consume the container, an fr track can calculate to 0px, but the browser still preserves the item’s minimum content width unless another constraint overrides it. section 4.3.5 section 4.6

Use min-content to reason about these related sizing behaviors:

  • auto tracks shrink toward min-content and grow toward max-content while respecting min-width and max-width. section 4.4.2
  • minmax(min-content, max-content) expresses the same intrinsic lower and upper bounds without auto’s additional width-property behavior. section 4.4.2
  • An empty track may display at 0px because it has no content contributing a minimum width. section 4.5

A flexible track that overflows

In a 300px container with 200px, 100px, and 1fr columns, the flexible track has no remaining space. If its padding and text require approximately 38px, its rendered width is calculated as max(0px, 38px) = 38px, so the column overflows rather than collapsing.

How Math for Web Design covers it

How deep it goes
Calculates intrinsic minimums and contrasts them with auto, max-content, minmax(), and explicit width constraints.
Examples
Uses longest unbreakable content, fixed-size elements, a 38px overflowing column, and an empty zero-width track.
What it assumes
Assumes familiarity with CSS Grid tracks, fr units, and basic width constraints.
What you can do after
Diagnose grid overflow by comparing a flexible track’s calculated size with its minimum content width.
How it connects
Connects min-content to CSS Grid, intrinsic sizing, max-content, auto, minmax(), fr units, and min-width.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.