grid
Widely availableSince 201797% of users
A shorthand property for setting all the explicit and implicit grid properties in a single declaration. It allows you to define rows, columns and templates quickly.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyClassicIt has worked everywhere since October 2017.
The old way and the modern waySee the snippet: Naming grid areas without line numbers →
Old way 15 lines
.header {
grid-column: 1 / -1;
}
.sidebar {
grid-column: 1;
grid-row: 2;
}
.main {
grid-column: 2;
grid-row: 2;
}
.footer {
grid-column: 1 / -1;
grid-row: 3;
}Modern 13 lines
.layout {
display: grid;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
}
.header {
grid-area: header;
}
.sidebar {
grid-area: sidebar;
}See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
See individual properties- Inherited
- No
- Applies to
- grid containers
Quick example
.container {
display: grid;
grid: 100px 1fr / 1fr 200px;
/* rows / columns */
}Values
grid-templategrid-template-rowsauto-flowdensegrid-auto-columnsgrid-auto-rowsgrid-template-columnsRelated snippet
Naming grid areas without line numbersLayout →grid browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2017.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
57+
52+
10.1+
16+Mobile
57+Android
52+Android
10.3+iOS