CSS: grid-template-areas

The grid-template-areas property creates a named map of Grid regions, making a page layout easier to read and rearrange.

What you will learn

Minimal example

.layout {
  display: grid;
  grid-template-areas:
    "header header"
    "nav main";
  grid-template-columns: 12rem 1fr;
}
.header { grid-area: header; }
.nav { grid-area: nav; }
.main { grid-area: main; }

Each quoted row describes one Grid row. Repeating a name makes one area span multiple cells; a dot represents an intentionally empty cell.

Common mistakes