CSS grid-template Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

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.

CSS Syntax

syntax.css
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.

Property Values

ValueDescriptionTry it
noneDefault. No explicit rows, columns, or areasTry it
<rows> / <columns>Sets row and column tracks; areas become noneTry it
Area stringsNamed areas in quotes; optional row size after each stringTry it
/ <columns>Optional column list after the area rowsTry it
initialResets to noneTry it
inheritTakes the parent value (not inherited by default)Try it

How to Use grid-template

Pick the short rows/columns form, or the areas form for page regions.

  1. Set display: grid on the container.
  2. For a simple board, write grid-template: <rows> / <columns>.
  3. For a layout sketch, write quoted area rows, then / and column sizes.
  4. Assign children with grid-area: name to match the strings.
FormSets
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

Live Preview

Change only grid-template. Items use fixed grid-area names a, b, and c.

With none, named areas disappear and items fall back to auto-placement.

Template
a
b
c

grid-template: areas + sizes

CSS Examples

Each snippet focuses on grid-template. Use Try It Yourself for a live editor.

Example 1 — Rows and Columns

The slash form sets tracks only. Areas stay none.

CSS
<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>
Try It Yourself

How It Works

  1. Before the slash. 40px 1fr creates two rows.
  2. After the slash. 1fr 1fr creates two equal columns.
  3. Areas reset. This form sets grid-template-areas to none.
  4. Items auto-fill. Children flow into the cells in order.

Example 2 — Named Areas

Quoted strings draw the layout. Columns follow the slash.

CSS
<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>
Try It Yourself

How It Works

  1. Draw the map. Each quoted string is one row of area names.
  2. Same name = merge. Two a cells side by side make a wide header.
  3. Set columns after /. 1fr 1fr sizes the two columns.
  4. 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.

CSS
<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>
Try It Yourself

How It Works

  1. String then size. "a a" 40px makes that row 40px tall.
  2. Second row flexes. "b c" 1fr takes remaining height.
  3. Columns at the end. / 1fr 1fr still defines both columns.
  4. 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 template

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

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.

96% global support
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.

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

It is a shorthand that sets grid-template-rows, grid-template-columns, and grid-template-areas on a grid container.
none — no explicit template. Tracks are created as needed using grid-auto-rows and grid-auto-columns.
In the rows / columns form, everything before the slash is rows and everything after is columns.
Both can set the explicit template. grid also resets implicit grid properties (like grid-auto-*) to their initials; grid-template does not.
Not in the ASCII-art areas form. That form lines areas up one-to-one with track sizes, so repeat() is not allowed there.
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.

Next: grid-template-areas

Deep dive into named area strings alone.

grid-template-areas tutorial →

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.

8 people found this page helpful