grid

grid-template-columns

Defines the number, size, and naming of columns in a grid container. Supports flexible fr units, repeat(), minmax(), and auto-fit/auto-fill for responsive layouts.

grid-template-columns: none | <track-list> (e.g. 1fr 2fr | repeat(3, 1fr) | minmax(200px, 1fr))

Common values

Value Effect
1fr 1fr 1fr Three equal-width columns
repeat(4, 1fr) Shorthand for four equal columns
repeat(auto-fit, minmax(240px, 1fr)) Responsive columns that fill the row
200px 1fr Fixed sidebar plus fluid main
auto Column sizes to its content

Examples

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }

Card grid that reflows across breakpoints

.layout { display: grid; grid-template-columns: 240px 1fr; }

Fixed sidebar, fluid main content

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); }

Even four-column KPI row

Gotcha

auto-fit collapses empty tracks, while auto-fill preserves them; pick based on whether you want stretched or empty slots.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox