CSS grid-template-columns Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout

What You’ll Learn

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.

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.

📝 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:

syntax.css
.container {
  grid-template-columns: track-size track-size ...;
}

Basic Example

grid-template-columns-basic.css
.container {
  display: grid;
  grid-template-columns: 100px 1fr 200px;
}

With repeat()

grid-template-columns-repeat.css
.container {
  grid-template-columns: repeat(3, 1fr);
}
grid-template-columns: none; grid-template-columns: 100px 1fr 200px; repeat(3, minmax(120px, 1fr))

Default Value

The default value of the grid-template-columns property is none, meaning no grid columns are defined and the grid container has no explicit columns.

Syntax Rules

  • Applies to grid containers only, not individual grid items.
  • Accepts length, percentage, fr, auto, minmax(), and repeat().
  • Each value creates one column track unless wrapped in repeat().
  • The property is not inherited.
  • Pair with grid-template-rows for full grid structure.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toGrid containers
InheritedNo
ControlsColumn track sizes
Flexible unitfr (fraction)

💎 Property Values

ValueDescription
lengthDefines a fixed size, such as 100px
percentageDefines a size relative to the grid container, such as 20%
autoAutomatically adjusts the column size based on content
frDefines a fraction of the available space, such as 1fr
minmax(min, max)Defines a size range with a minimum and maximum value
repeat(count, track-size)Repeats a pattern of columns a specified number of times

👀 Live Preview

Three columns with grid-template-columns: 3rem 1fr 4rem (middle column flexible):

1
2
3

Examples Gallery

Create fixed and flexible columns, use repeat() for equal columns, apply minmax() for responsive sizing, and build an auto-fit card grid.

🔢 Column Track Sizing

Start with the reference example — fixed, flexible, and fixed columns.

Example 1 — 100px, 1fr, and 200px

Create a grid with three columns: a fixed sidebar, a flexible main area, and a fixed aside.

grid-template-columns-fixed-flex.css
.container {
  display: grid;
  grid-template-columns: 100px 1fr 200px;
  gap: 10px;
}
Try It Yourself

How It Works

The first and third columns stay at fixed widths. The middle 1fr column absorbs all remaining horizontal space.

Example 2 — Three Equal Columns with repeat()

Use repeat() to avoid listing the same track size multiple times.

grid-template-columns-repeat-example.css
.container {
  grid-template-columns: repeat(3, 1fr);
}
Try It Yourself

How It Works

repeat(3, 1fr) is shorthand for 1fr 1fr 1fr, creating three equal flexible columns.

📈 Responsive Columns

Use minmax() and auto-fit for layouts that adapt to container width.

Example 3 — minmax() for Flexible Bounds

Set a minimum and maximum column width so columns stay readable.

grid-template-columns-minmax.css
.container {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}
Try It Yourself

How It Works

Each column is at least 120px wide but can grow to share space equally with 1fr as the maximum.

Example 4 — Auto-Fit Card Grid

Let columns wrap automatically based on available space using auto-fit.

grid-template-columns-autofit.css
.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}
Try It Yourself

How It Works

auto-fit creates as many columns as fit at the minimum width. Extra space is distributed among existing columns.

♿ 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.

🖥 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 Chrome 57+ · Desktop & Mobile
Full support
Mozilla Firefox 52+ · Desktop & Mobile
Full support
Apple Safari 10.1+ · macOS & iOS
Full support
Microsoft Edge 16+ · 79+ Chromium
Full support
Opera 44+
Full support
grid-template-columns property 97% supported

Bottom line: Safe for modern projects. Test auto-fit and minmax() patterns at different viewport widths.

🎉 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.

💡 Best Practices

✅ Do

  • Use fr for flexible columns
  • Use repeat() for equal column patterns
  • Apply minmax() for responsive bounds
  • Pair with gap for clean spacing
  • Test layouts at narrow and wide widths

❌ Don’t

  • Apply on grid items instead of containers
  • Use too many fixed px columns on mobile
  • Forget display: grid on the container
  • Mix conflicting track sizes without testing
  • Overuse auto-fit without a sensible min width

Key Takeaways

Knowledge Unlocked

Five things to remember about grid-template-columns

Use these points when sizing grid columns.

5
Core concepts
none 02

Default none

No tracks.

Default
1fr 03

Fraction

Flexible.

Syntax
repeat 04

repeat()

Patterns.

Pattern
min 05

minmax()

Bounds.

Responsive

❓ Frequently Asked Questions

grid-template-columns defines the number and size of column tracks in a CSS grid container.
The default is none, which means no explicit columns are defined on the grid container.
1fr means one fraction of the remaining free space in the grid container after fixed-size tracks are calculated.
grid-template-columns sets only column track sizes. grid-template is shorthand that can include rows, columns, and named areas together.
Use repeat(3, 1fr) for three equal columns, or list multiple 1fr values such as 1fr 1fr 1fr.

Practice in the Live Editor

Open the HTML editor, change grid-template-columns values, and see how column widths update.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful