The grid-template-areas property defines named regions on a grid container using readable string rows.
01
Named areas
Region labels.
02
Strings
One per row.
03
none
Default.
04
grid-area
Assign items.
05
Dot .
Empty cell.
06
Container
Grid parent.
Fundamentals
Introduction
The grid-template-areas property in CSS is part of the CSS Grid Layout module. It allows you to define named grid areas within a grid container, making it easier to design complex layouts with a clear, readable syntax.
Definition and Usage
Set grid-template-areas on a grid container with display: grid. Each quoted string represents one row. Area names in the same row are separated by spaces. Assign items to those areas using grid-area on child elements.
💡
Beginner Tip
Repeat the same name across cells to make an area span multiple columns or rows. Every row string must have the same number of cells.
Foundation
📝 Syntax
The syntax for the grid-template-areas property uses strings to represent the grid layout. Each string defines a row, with named areas enclosed in quotes:
syntax.css
.container{display:grid;grid-template-areas:"header header header""sidebar main main""footer footer footer";}
hero spans all three columns. aside repeats in two rows to form a tall sidebar beside featured and card content.
A11y
♿ Accessibility
Keep DOM order meaningful when named areas reorder visual layout.
Use semantic HTML such as <header>, <nav>, <main>, and <aside>.
Do not rely on area names alone to convey structure; use headings and landmarks.
Test keyboard tab order when sidebar and main are visually reordered.
Override area strings in media queries for readable mobile layouts.
🧠 How grid-template-areas Works
1
Area strings are written
Each quoted row lists area names separated by spaces.
Strings
2
Browser maps regions
Repeated names merge into rectangular named areas on the grid.
Regions
3
Items use grid-area
Child elements assign themselves to a name with grid-area.
Assign
=
▦
Readable layout code
The CSS visually mirrors the page structure, making layouts easy to maintain.
Compatibility
🖥 Browser Compatibility
The grid-template-areas property is well-supported in modern browsers, including recent versions of Chrome, Firefox, Safari, Edge, and Opera.
✓ Baseline · Modern browsers
grid-template-areas everywhere
Named grid areas work in all major modern grid implementations.
97%Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox52+ · Desktop & Mobile
Full support
Apple Safari10.1+ · macOS & iOS
Full support
Microsoft Edge16+ · 79+ Chromium
Full support
Opera44+
Full support
grid-template-areas property97% supported
Bottom line: Safe for modern projects. Test area layouts across target browsers and screen sizes.
Wrap Up
🎉 Conclusion
The grid-template-areas property is a powerful feature of CSS Grid Layout, making it easier to create complex and responsive layouts with clean and readable code. By defining named grid areas, you can efficiently manage the placement of content and maintain a clear structure in your stylesheets.
Experiment with different grid layouts and see how this property can enhance your web design projects. Pair it with grid-area on child items and override area strings in media queries for responsive designs.