Grid Areas and Placement
grid-template-areas lets you draw the layout with names, and each child claims an area through grid-area. You can also place items by line numbers with grid-column and grid-row, such as grid-column: 1 / 3 to span two columns, or grid-column: span 2.
Named areas make layouts easy to read and easy to rearrange inside media queries.
Example
<style>
.page {
display: grid;
grid-template-columns: 120px 1fr;
grid-template-areas:
"head head"
"side main"
"foot foot";
gap: 8px;
}
.page > * { padding: 12px; background: #e0e7ff; border-radius: 6px; }
.head { grid-area: head; background: #818cf8; }
.side { grid-area: side; }
.main { grid-area: main; }
.foot { grid-area: foot; background: #a5b4fc; }
</style>
<div class="page">
<div class="head">Header</div>
<div class="side">Side</div>
<div class="main">Main</div>
<div class="foot">Footer</div>
</div>Exercise
Make the item span two columns.
.wide { grid-column: 2; }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.