CSS Grid areas let you describe a layout as named cells, one row at a time, then place elements into those regions with grid-area. Repeated names create larger rectangular regions; a period (.) marks an intentionally empty cell.
How CSS Grid areas work
Put grid-template-areas on a grid container. Each quoted string represents one row, and each whitespace-separated token in that string represents a cell. The MDN Web Docs definition is direct: “The grid-template-areas CSS property specifies named grid areas, establishing the cells in the grid and assigning them names.” MDN’s property reference documents the syntax and rules.
As an Amazon Associate I earn from qualifying purchases.
Names in the map define regions, but they do not automatically put child elements there. Give each child a matching grid-area value. A name repeated in adjacent cells makes one area spanning those cells.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Build a compact page layout
This example lays out a header, navigation, main content, and footer. Its two columns are sized separately from the area map, and gap adds space between tracks.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
.page {
display: grid;
grid-template-columns: 12rem 1fr;
grid-template-areas:
"header header"
"nav main"
". footer";
gap: 1rem;
}
header { grid-area: header; }
nav { grid-area: nav; }
main { grid-area: main; }
footer { grid-area: footer; }
- The first row assigns both cells to
header, so the header spans two columns. - The second row places navigation beside the main content.
- The period leaves the lower-left cell empty; the footer occupies the cell to its right.
Named areas establish placement, not track sizing. Use declarations such as grid-template-columns and grid-template-rows when you need to control column or row sizes. For a broader overview of grid tracks and placement, see MDN’s CSS grid layout guide.
Leave a blank space or span a region
Use a period as a null cell token when a cell should not belong to a named area. It is a placeholder in the map, not an area name, and not every cell needs a name.
Rank #2
To make an area span multiple cells, repeat its name in neighboring positions. The repeated cells must form a rectangle: a region can be one cell, a row or column of cells, or a larger rectangular block. A disconnected or L-shaped arrangement of the same name makes the grid-template-areas declaration invalid.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rearrange the layout at a breakpoint
You can replace the area map inside a media query while keeping the same elements and their grid-area assignments. For a narrow screen, this map stacks the header, main content, navigation, and footer:
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
@media (max-width: 40rem) {
.page {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"main"
"nav"
"footer";
}
}
Here the map changes both the arrangement and the number of columns, so the one-column track definition accompanies the new one-cell-wide rows. MDN also illustrates redefining named areas at breakpoints in its grid template areas guide.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Named areas or line-based placement?
Named areas are an alternate way to place grid items and can be combined with line-based placement, as described in MDN’s grid-area reference. Choose according to the shape of the layout rather than treating one method as universally better.
Rank #4
| Consideration | Named areas | Line-based placement |
|---|---|---|
| Communicating the intended layout | A row-by-row map makes regions such as header, navigation, and main content visible in the CSS. | Placement is expressed through grid line positions or spans rather than a named map. |
| Precise line or span control | Useful when the design maps cleanly to named rectangular regions. | Useful when placement needs explicit grid-line or span values. |
| Changing placement at breakpoints | Redefine the map to show a different arrangement. | Change the relevant line-based placement values. |
A practical approach is to use named areas for the large regions whose relationships you want to read at a glance, and line-based placement where exact line or span control fits better.
Quick Recap
Best Value
Check these details when a layout does not match the map
- Confirm the parent has
display: grid; the area map belongs on the grid container. - Check that each item’s
grid-areavalue matches a name in the active map. - Count the cells in each row: every quoted row must describe the same number of columns.
- Check repeated names for one connected rectangular shape; a missing or misplaced token can make a region invalid.
- Set the needed columns and rows separately. Named areas do not decide their track sizes.
- For responsive rules, make sure the map at the current viewport includes the regions the items are assigned to.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




