Home CSS Properties grid-template CSS grid-template Property Definition
Definition and Usage The grid-template property is a shorthand for grid-template-rows , grid-template-columns , and grid-template-areas . Set it on a grid container (display: grid ).
The initial value is none. Use the grid shorthand instead when you also want to reset implicit tracks (grid-auto-*). Place items into named areas with grid-area .
Standard-track. Not deprecated and not experimental. Baseline widely available with CSS Grid.
Syntax
CSS Syntax grid-template: none | <rows> / <columns> | <areas + row sizes> [ / <columns> ]? | initial | inherit ;
Two common forms: rows / columns, or ASCII-art areas with optional sizes and a trailing / columns.
Values
Property Values Value Description Try it noneDefault. No explicit rows, columns, or areas Try it<rows> / <columns>Sets row and column tracks; areas become none Try itArea strings Named areas in quotes; optional row size after each string Try it/ <columns>Optional column list after the area rows Try itinitialResets to none Try itinheritTakes the parent value (not inherited by default) Try it
Approach
How to Use grid-template Pick the short rows/columns form, or the areas form for page regions.
Set display: grid on the container. For a simple board, write grid-template: <rows> / <columns>. For a layout sketch, write quoted area rows, then / and column sizes. Assign children with grid-area: name to match the strings. Form Sets 100px 1fr / 1fr 1frRows + columns only "a a" "b c" / 1fr 1frAreas + columns (row sizes default to auto) "a a" 40px "b c" 1fr / 1fr 1frAreas + row sizes + columns
Try it
Live Preview Change only grid-template. Items use fixed grid-area names a, b, and c.
Code
CSS Examples Each snippet focuses on grid-template. Use Try It Yourself for a live editor.
1. Rows / columns 2. Named areas 3. Areas + sizes Example 1 — Rows and Columns The slash form sets tracks only. Areas stay none.
<style>
.grid {
display: grid;
grid-template: 40px 1fr / 1fr 1fr;
}
</style>
<div class="grid">
<div>1</div><div>2</div>
<div>3</div><div>4</div>
</div> How It Works Before the slash. 40px 1fr creates two rows.After the slash. 1fr 1fr creates two equal columns.Areas reset. This form sets grid-template-areas to none.Items auto-fill. Children flow into the cells in order.Example 2 — Named Areas Quoted strings draw the layout. Columns follow the slash.
<style>
.grid {
display: grid;
grid-template:
"a a"
"b c"
/ 1fr 1fr;
}
.a { grid-area: a; }
.b { grid-area: b; }
.c { grid-area: c; }
</style>
<div class="grid">
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
</div> How It Works Draw the map. Each quoted string is one row of area names.Same name = merge. Two a cells side by side make a wide header.Set columns after /. 1fr 1fr sizes the two columns.Hook items up. grid-area: a places the child into that named region.Example 3 — Areas with Row Sizes Put a track size after each area string.
<style>
.grid {
display: grid;
grid-template:
"a a" 40px
"b c" 1fr
/ 1fr 1fr;
}
.a { grid-area: a; }
.b { grid-area: b; }
.c { grid-area: c; }
</style>
<div class="grid">
<div class="a">a</div>
<div class="b">b</div>
<div class="c">c</div>
</div> How It Works String then size. "a a" 40px makes that row 40px tall.Second row flexes. "b c" 1fr takes remaining height.Columns at the end. / 1fr 1fr still defines both columns.No repeat() here. The areas form expects one size per drawn row. Edge Cases & Pitfalls One shorthand resets three longhands. Watch the form you pick.
reset Slash form clears areas grid-template: 1fr / 1fr 1fr sets areas to none. Earlier named areas are wiped by that declaration.
vs grid grid resets more than the templateThe grid shorthand also resets implicit properties. Prefer grid-template when you only want the explicit template.
repeat No repeat() in the areas form ASCII-art rows must line up with sizes. Use the longhands if you need repeat() with areas.
strings Area rows must match width Every quoted row needs the same number of cells. Uneven strings make the areas invalid.
dot Use . for empty cells A period in an areas string leaves a cell unnamed so nothing claims that spot by area name.
Compatibility
Browser Support grid-template is a browser style property for CSS Grid. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
grid-template Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+, Opera, Samsung Internet 6+. Not supported in Internet Explorer.
Google Chrome 57+
Full support
Mozilla Firefox 52+
Full support
Apple Safari 10.1+
Full support
Microsoft Edge 16+
Full support
Opera 44+
Full support
Samsung Internet 6+
Full support
Internet Explorer All
Not supported grid-template Supported with modern CSS Grid
Bottom line: Safe for modern grid layouts. No vendor prefix is required in current browsers.
Remember
Key Takeaways Role: shorthand for rows, columns, and areas.
Slash form: rows / columns (areas become none).
Areas form: quoted strings, optional sizes, then / columns.
vs grid: use grid-template when you must not reset auto tracks.
One line: grid-template defines the explicit grid’s rows, columns, and named areas together.
Frequently Asked Questions What does grid-template do? It is a shorthand that sets grid-template-rows, grid-template-columns, and grid-template-areas on a grid container.
What is the default value? none — no explicit template. Tracks are created as needed using grid-auto-rows and grid-auto-columns.
What does the slash mean? In the rows / columns form, everything before the slash is rows and everything after is columns.
How is grid-template different from the grid shorthand? Both can set the explicit template. grid also resets implicit grid properties (like grid-auto-*) to their initials; grid-template does not.
Can I use repeat() with named areas? Not in the ASCII-art areas form. That form lines areas up one-to-one with track sizes, so repeat() is not allowed there.
Which browsers support grid-template? It is Baseline widely available: Chrome 57+, Firefox 52+, Safari 10.1+, Edge 16+. It is a browser style property, not a Node.js feature.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion