CSS grid-template-areas Property

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

What You’ll Learn

The grid-template-areas property defines named regions on a grid container using readable string rows.

01

Named areas

Region labels.

02

Strings

One per row.

03

none

Default.

04

grid-area

Assign items.

05

Dot .

Empty cell.

06

Container

Grid parent.

Introduction

The grid-template-areas property in CSS is part of the CSS Grid Layout module. It allows you to define named grid areas within a grid container, making it easier to design complex layouts with a clear, readable syntax.

Definition and Usage

Set grid-template-areas on a grid container with display: grid. Each quoted string represents one row. Area names in the same row are separated by spaces. Assign items to those areas using grid-area on child elements.

💡
Beginner Tip

Repeat the same name across cells to make an area span multiple columns or rows. Every row string must have the same number of cells.

📝 Syntax

The syntax for the grid-template-areas property uses strings to represent the grid layout. Each string defines a row, with named areas enclosed in quotes:

syntax.css
.container {
  display: grid;
  grid-template-areas:
    "header header header"
    "sidebar main main"
    "footer footer footer";
}

Assign Items to Areas

grid-template-areas-assign.css
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
grid-template-areas: none; "a b" "c d" "hd hd" ". main"

Default Value

The default value of the grid-template-areas property is none, meaning no named grid areas are defined.

Syntax Rules

  • Applies to grid containers only, not individual grid items.
  • Each string must have the same number of area tokens (columns).
  • Repeated names in adjacent cells form one rectangular area.
  • Use a dot (.) for empty cells that should not hold content.
  • The property is not inherited.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toGrid containers
InheritedNo
ControlsNamed grid regions
Pair withgrid-area on items

💎 Property Values

ValueDescription
noneNo grid areas are defined
stringA sequence of strings, each representing a row with named areas separated by spaces

👀 Live Preview

A page layout with header, sidebar, main, and footer defined by grid-template-areas:

Header
Side
Main
Footer

Examples Gallery

Build a classic page layout, create a simple 2×2 grid, leave empty cells with a dot, and design a magazine-style hero layout.

🔢 Named Area Layouts

Start with the reference example — header, sidebar, main content, and footer.

Example 1 — Classic Page Layout

Create a simple layout with a header, sidebar, main content area, and footer.

grid-template-areas-page.css
.container {
  display: grid;
  grid-template-areas:
    "header header header"
    "sidebar main main"
    "footer footer footer";
  gap: 10px;
}

.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }
Try It Yourself

How It Works

Repeating header three times spans the full width. main spans two columns beside the sidebar. Each item uses grid-area to snap into its named region.

Example 2 — Simple 2×2 Named Grid

Define four distinct areas with one name per cell.

grid-template-areas-2x2.css
.grid {
  grid-template-areas:
    "a b"
    "c d";
}
Try It Yourself

How It Works

Two strings with two names each create a 2×2 grid. Each unique name maps to one cell region.

📈 Advanced Patterns

Use empty cells and spanning names for richer layouts.

Example 3 — Empty Cells with a Dot

Leave the top-left cell empty using . in the area string.

grid-template-areas-empty.css
.grid {
  grid-template-areas:
    ". nav nav"
    "aside content content";
}
Try It Yourself

How It Works

The dot marks a cell with no named area. Nav spans two columns on the first row while the first column stays empty.

Example 4 — Magazine Hero Layout

Span a hero banner across the full width with featured content below.

grid-template-areas-magazine.css
.magazine {
  grid-template-areas:
    "hero hero hero"
    "feat feat aside"
    "card card aside";
}
Try It Yourself

How It Works

hero spans all three columns. aside repeats in two rows to form a tall sidebar beside featured and card content.

♿ Accessibility

  • Keep DOM order meaningful when named areas reorder visual layout.
  • Use semantic HTML such as <header>, <nav>, <main>, and <aside>.
  • Do not rely on area names alone to convey structure; use headings and landmarks.
  • Test keyboard tab order when sidebar and main are visually reordered.
  • Override area strings in media queries for readable mobile layouts.

🧠 How grid-template-areas Works

1

Area strings are written

Each quoted row lists area names separated by spaces.

Strings
2

Browser maps regions

Repeated names merge into rectangular named areas on the grid.

Regions
3

Items use grid-area

Child elements assign themselves to a name with grid-area.

Assign
=

Readable layout code

The CSS visually mirrors the page structure, making layouts easy to maintain.

🖥 Browser Compatibility

The grid-template-areas property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.

Baseline · Modern browsers

grid-template-areas everywhere

Named grid areas work 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-areas property 97% supported

Bottom line: Safe for modern projects. Test area layouts across target browsers and screen sizes.

🎉 Conclusion

The grid-template-areas property is a powerful feature of CSS Grid Layout, making it easier to create complex and responsive layouts with clean and readable code. By defining named grid areas, you can efficiently manage the placement of content and maintain a clear structure in your stylesheets.

Experiment with different grid layouts and see how this property can enhance your web design projects. Pair it with grid-area on child items and override area strings in media queries for responsive designs.

💡 Best Practices

✅ Do

  • Use descriptive area names like header and main
  • Keep each row string the same length
  • Pair with grid-area on child items
  • Use dots for intentionally empty cells
  • Change area strings in media queries for mobile

❌ Don’t

  • Apply on grid items instead of containers
  • Create non-rectangular area shapes
  • Use mismatched column counts per row
  • Forget display: grid on the container
  • Rely on visual order alone for accessibility

Key Takeaways

Knowledge Unlocked

Five things to remember about grid-template-areas

Use these points when naming grid regions.

5
Core concepts
none 02

Default none

No areas.

Default
" " 03

Strings

One per row.

Syntax
. 04

Empty dot

Blank cell.

Pattern
area 05

grid-area

Assign items.

Workflow

❓ Frequently Asked Questions

grid-template-areas defines named regions on a grid container using strings, where each string represents one row of area names.
The default is none, which means no named grid areas are defined on the container.
grid-template-areas sets only the named area strings. grid-template is shorthand that can include areas plus row and column sizes.
Use a dot (.) or multiple dots in the string for cells that should stay empty. For example: "header header" ". main".
grid-template-areas defines area names on the container. grid-area assigns an individual item to one of those named areas.

Practice in the Live Editor

Open the HTML editor, change grid-template-areas strings, and watch layout regions 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