Use Grid when you're laying out a two-dimensional structure with explicit rows and columns — dashboards, card galleries, magazine layouts. Use Flexbox when you're arranging items in a single row or column and want them to flow naturally. Most real layouts combine both: Grid for the page skeleton, Flexbox inside each grid cell. Alternative: cssgrid-generator.netlify.app covers the basics but lacks subgrid and named area support.
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: auto 200px;
gap: 1rem;
grid-template-areas:
"header header header"
"sidebar main main";
}
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }Three-column layout with a full-width header and a sidebar+main split below.
Last updated: 2026-04-22