HTML & CSS · Grid Layout · Lesson 15 of 25
Grid Template Areas
Concept
Grid Template Areas
grid-template-areas lets you name regions of your layout and place elements into them by name.
Because the CSS literally looks like a visual map of the layout, grid-template-areas is often the easiest way to read and reason about a page's overall structure at a glance.
By the end of this lesson
- Explain the core idea behind Grid Template Areas.
- Predict output before running a change.
- Test one realistic and one unusual input.
- Use the result to make the next decision.
How to study this page
- 1. Read one concept.
- 2. Change the example.
- 3. Run, compare, and explain.
- 4. Complete the challenge below.
Syntax
.layout {
display: grid;
grid-template-areas:
"header header"
"sidebar main";
}
.header { grid-area: header; }ExampleRunnable
.layout {
display: grid;
grid-template-areas: "header header" "sidebar main";
}Try it Yourself »Assigning elements to named areas
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }Self-check before continuing
Without looking at the example, describe what changes when you modify one input in Grid Template Areas. Then reopen the editor and prove your explanation with a small test.
You are ready to continue when you can predict, test, and explain the result.
Your turn
Sketch a grid-template-areas layout for a page with a header, sidebar, and main content.
Loading editor…
Console