Grid Template Areas
What are Grid Template Areas?
Grid template areas let you name sections of your grid and create layouts visually in CSS. It's incredibly readable and semantic!
Basic Layout with Areas
Use grid-template-areas to define named regions, then assign
items to areas with grid-area.
Classic Website Layout
Create a classic header-sidebar-content-footer layout with named areas. Notice how readable the CSS is!
Empty Cells with Dots
Use a dot . to create empty cells in your grid
template.
Responsive Grid Areas
Change grid-template-areas with media queries for responsive layouts. Desktop: sidebar on left. Mobile: sidebar below content.
Summary
grid-template-areas- Define named grid regionsgrid-area- Assign element to named area- Use quotes for each row in template-areas
- Repeat area name to span multiple cells
- Use
.for empty cells - Perfect for semantic, readable layouts
Quick Quiz
What character creates an empty cell in grid-template-areas?
Enjoying these tutorials?