What You'll Learn
You'll discover how to place a grid item in one compact line by specifying all four boundaries at once using the grid-area property.
The All-In-One Placement Property
You've already learned to control where grid items sit using grid-row and grid-column. Now there's an even more condensed way: grid-area combines all four placement values into a single property.
The syntax follows this specific order:
grid-area: row-start / column-start / row-end / column-end;
Think of it like giving someone directions using compass points: "Start at intersection 2-North and 1-West, end at 4-South and 3-East." You're defining a rectangular region by naming all four boundaries.
Practical Example
Instead of writing this:
.item {
grid-row-start: 1;
grid-column-start: 2;
grid-row-end: 3;
grid-column-end: 4;
}
You can write:
.item {
grid-area: 1 / 2 / 3 / 4;
}
Both approaches do exactly the same thing—place the item starting at row line 1 and column line 2, ending at row line 3 and column line 4.
You can also use the span keyword and named lines:
.item {
grid-area: 1 / 1 / span 2 / span 3;
/* Starts at row 1, column 1, spans 2 rows and 3 columns */
}
When to Use It
Use grid-area when you know all four boundaries and want cleaner, more compact code. The shorthand is especially helpful when creating complex grid layouts where items need precise positioning.
Key Takeaway: grid-area lets you specify row-start, column-start, row-end, and column-end in a single line, using the syntax row-start / column-start / row-end / column-end.