Skip to content

Named Areas

Line numbers are precise.

But they can also get… gross.

Named areas let you design a layout like a map:

  • header
  • sidebar
  • content
  • footer

That’s what grid-template-areas is for: readable layout intent.


.layout {
display: grid;
grid-template-columns: 14rem 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
'header header'
'sidebar content'
'footer footer';
}

The strings describe the grid.


header {
grid-area: header;
}
aside {
grid-area: sidebar;
}
main {
grid-area: content;
}
footer {
grid-area: footer;
}

Now your HTML can stay semantic, and the grid does the layout work.


You can leave cells unused with .

grid-template-areas:
'header header'
'. content'
'footer footer';

Swap blueprints.
Watch the layout rewire itself.


Areas are the readable option:

  • great for page layout
  • easy to refactor
  • less fragile than line-number spaghetti

📘 Grid Template Areas Study Guide (PDF)

📘 Grid Template Areas Infographic (PNG)

Infographic explaining CSS Flexbox direction and axes, showing how flex-direction defines the main axis and cross axis, with visual examples for row, row-reverse, column, and column-reverse, and how justify-content and align-items map to each axis.

⏭ Shuffle Along: Responsive Template Areas

Section titled “⏭ Shuffle Along: Responsive Template Areas”

Restructure pages responsively (and responsibility).