The grid-template-columns property defines the number and size of column tracks in a CSS grid container.
01
Columns
Track sizes.
02
none
Default.
03
1fr
Flexible.
04
px
Fixed size.
05
repeat()
Patterns.
06
minmax()
Range.
Fundamentals
Introduction
The grid-template-columns property in CSS is a fundamental part of the CSS Grid Layout Module. It defines the columns of a grid container, specifying the size and number of columns. This property allows developers to create complex, responsive layouts with ease.
Definition and Usage
Set grid-template-columns on a grid container with display: grid. List track sizes separated by spaces, or use functions like repeat() and minmax() for flexible patterns.
💡
Beginner Tip
100px 1fr 200px creates three columns: fixed, flexible, and fixed. The middle column grows to fill remaining space.
Foundation
📝 Syntax
The syntax for the grid-template-columns property involves defining one or more track sizes, which can be a length, a percentage, a fraction, or the keyword auto:
auto-fit creates as many columns as fit at the minimum width. Extra space is distributed among existing columns.
A11y
♿ Accessibility
Use adequate column width so text remains readable without horizontal scrolling.
Test at narrow viewports when using fixed pixel columns.
Prefer minmax() and auto-fit for responsive layouts that adapt to zoom.
Keep DOM order logical even when columns reorder visually on small screens.
Do not rely on column position alone to convey meaning; use headings and labels.
🧠 How grid-template-columns Works
1
Grid container is created
display: grid enables grid formatting context.
Grid
2
Column tracks are defined
You list sizes like px, fr, or repeat() for each column track.
Columns
3
Browser sizes tracks
Fixed sizes are applied first; fr units share remaining space.
Sizing
=
▦
Structured column layout
Items auto-place into columns or span them with grid placement properties.
Compatibility
🖥 Browser Compatibility
The grid-template-columns property is widely supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.
✓ Baseline · Modern browsers
grid-template-columns everywhere
Column track sizing works in all major modern grid implementations.
97%Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox52+ · Desktop & Mobile
Full support
Apple Safari10.1+ · macOS & iOS
Full support
Microsoft Edge16+ · 79+ Chromium
Full support
Opera44+
Full support
grid-template-columns property97% supported
Bottom line: Safe for modern projects. Test auto-fit and minmax() patterns at different viewport widths.
Wrap Up
🎉 Conclusion
The grid-template-columns property is an essential tool for web developers working with CSS Grid. By defining the size and number of columns in a grid container, you can create flexible, responsive layouts that adapt to different screen sizes and content requirements.
Experiment with different values and combinations to see how this property can enhance your web designs. Start with fixed and fr units, then explore repeat() and minmax() for responsive patterns.