Description & Usage

The grid-template-columns property is the core configuration for CSS Grid column layouts. It specifies the number of columns and their respective widths using track sizing functions.

Grid introduces powerful CSS units like fractional units (fr), which divide remaining free space proportionally among tracks. Combined with repeat() and minmax(), developers can build fully fluid multi-column layouts that auto-fit to screen size without media queries.

For example, repeat(auto-fit, minmax(250px, 1fr)) automatically creates as many 250px+ columns as can fit on screen, wrapping gracefully when space runs out.

Property Specifications

Property FeatureSpecification
CategoryGrid
Initial Valuenone
InheritedNo (not inherited)
Applies ToGrid containers
Grid Visualizer
Items:
6
repeat(3, 1fr)
12px
Box 1
Box 2
Box 3
Box 4
Box 5
Box 6
.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: stretch; justify-items: stretch; }

Syntax

grid-template-columns: none | repeat(3, 1fr) | 200px 1fr | repeat(auto-fit, minmax(200px, 1fr));

Property Values

ValueDescription
repeat(N, 1fr)Creates N equal-width columns sharing available space.
1fr 2frFirst column gets 1 fraction, second column gets double space.
repeat(auto-fit, minmax(200px, 1fr))Creates responsive fluid grid without media queries.

Code Examples

Responsive 3-Column Card Layout
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
Automatically wraps cards to new lines on smaller screens.