grid-template-columns
Defines the number and widths of columns in a grid. You can set fixed sizes, percentages, or use the fr unit to fill available space.
Quick example
.container {
display: grid;
grid-template-columns: 200px 1fr 1fr;
} /* one fixed column, two flexible ones */ Syntax
grid-template-columns: <track-list> | none | subgrid<length><flex> (fr unit)autominmax(min, max)repeat(count, track)subgridQuick facts
noneExamples
Responsive cards without media queries
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1rem;
} Cards are at least 240px wide. Grid fits as many as possible per row and wraps when there is not enough space. No media queries needed.
Fixed sidebar with flexible main
.layout {
display: grid;
grid-template-columns: 240px 1fr;
} Sidebar stays at 240px, main content fills the remaining space. Classic app layout.
Equal columns that can shrink
.row {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
} Three equal columns. The minmax(0, 1fr) lets columns shrink below their content size, preventing content overflow from pushing columns wider.
grid-template-columns Browser Support
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2017.
Safe to use without fallbacks.
Common pitfalls
1fr has an implicit minimum of auto, which means the column will not shrink below its content size. If you have long text or wide images, columns can stretch beyond 1fr. Use minmax(0, 1fr) to force columns to truly share equal space.
auto-fit collapses empty columns, so remaining items stretch to fill the row. auto-fill keeps empty tracks reserved, so items stay at their minmax minimum width. Pick auto-fit for flexible cards and auto-fill for grids with fixed column slots.
In older browsers, 50% columns in a grid with gap could overflow because gap was added on top. Modern implementations size tracks to fit after gaps are subtracted, but verify if supporting older builds.
See also
grid-template-rowsgrid-template-areasgrid-columngap