🧱 CSS column-fill β€” Complete Tutorial

🌐 What Is column-fill?

The column-fill property controls **how content is distributed** across columns in a CSS Multi-Column Layout. By default, browsers try to balance content evenly across columns, but column-fill lets you change that behavior.

>>β€œUse column-fill when you want to control whether columns are balanced or filled sequentially.”

Note

βœ” Works only with CSS multi-column layouts
βœ” Controls column behavior for paged or multi-column content
βœ” auto and balance are the primary values

πŸ“¦ Syntax

column-fill syntax

column-fill: auto | balance;
ValueDescription
balanceDefault (except for paged media). Browser tries to distribute content evenly across all columns.
autoFills columns sequentially (one column after another). The last column may be shorter.

πŸ“Œ 1. Basic Example β€” Balanced Columns (Default)

Balanced columns

.content {
  column-count: 3;
  column-fill: balance; /* default */
}

Content is evenly distributed across all 3 columns.

πŸ“Œ 2. column-fill: auto β€” Fill One Column at a Time

Sequential fill

.content {
  column-count: 3;
  column-fill: auto;
}

Content flows into column 1, then column 2, then column 3 β€” creating unbalanced columns.

Note

auto is especially useful for paginated documents or print layouts.

πŸ“Œ 3. Combining Column Fill With Column Height

Fixed height container

.container {
  height: 300px;
  column-count: 3;
  column-fill: auto;
  overflow: auto;
}

A fixed-height box with sequential columns can create scrollable newspaper-style blocks.

πŸ“Œ 4. Multi-Column Cards (Manual Fill Strategy)

Card collection

.cards {
  column-count: 4;
  column-fill: auto;
  column-gap: 20px;
}

.card {
  break-inside: avoid;
}

Avoids splitting cards and makes a waterfall-like layout using column auto-fill.

πŸ“Œ 5. Balanced vs Auto β€” Visual Example

βœ” Balanced

Balanced example

.balanced {
  column-count: 3;
  column-fill: balance;
}

βœ” Auto

Auto example

.auto {
  column-count: 3;
  column-fill: auto;
}

Balanced mode tries to make all columns equal height. Auto mode fills one completely before moving to the next.

πŸ“Œ 6. Using With column-width

column-width + column-fill

.text {
  column-width: 200px;
  column-fill: auto;
}

When using column-width, the browser chooses how many columns fit based on container size, then column-fill determines how to fill them.

πŸ“Œ 7. Print Media Use Case

Paged content

@media print {
  .chapter {
    column-count: 2;
    column-fill: auto;
  }
}

print mode uses auto behavior naturally because pages must fill from top to bottom sequentially.

πŸ§ͺ Real-World Examples

1️⃣ Magazine-Style Layout

Magazine content

.magazine {
  column-count: 3;
  column-gap: 40px;
  column-fill: balance;
}

2️⃣ Style a Recipe Book (Print)

Recipe columns

@media print {
  .recipe {
    column-count: 2;
    column-fill: auto;
  }
}

3️⃣ Multi-Column Sidebar

Sidebar

.sidebar {
  column-count: 2;
  column-fill: balance;
  column-rule: 2px solid #eee;
}

⚠️ Common Mistakes

  • ❌ Expecting column-fill to control column height directly
  • ❌ Forgetting that balance is default in screen layouts
  • ❌ Using auto in responsive layouts without overflow handling
  • ❌ Thinking multi-columns behave like CSS Grid (they don’t)

Note

Multi-column layout is meant for text flow β€” use Grid if you need strict alignment and row/column control.

πŸ”₯ Summary

The column-fill property determines how content flows into the columns of a multi-column layout. Use balance when you want evenly sized columns, and auto when you want sequential filling (common in printing and paginated content).

>>β€œColumn fill decides whether your layout feels like a magazine or a book.”

Learn more β†’MDN Docs πŸ“˜