JavaScript Curriculum
CSS Grid
mediumThe coffee shop needs a real page layout — header spanning the full width, sidebar for categories, main content area, and a footer. Grid makes this a 10-line CSS solution.
CSS Grid
CSS Grid is a two-dimensional layout system — it handles rows and columns simultaneously. Where Flexbox thinks in one direction at a time, Grid thinks in both at once. It's the right tool for full-page layouts, photo galleries, dashboards, and any design with a defined structure.
grid-template-columns and rows
The foundation of Grid: define your column and row tracks, then let items flow in:
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto auto;
gap: 12px;
}Placing Items on the Grid
Grid items can be placed automatically or precisely positioned using line numbers, spans, or named areas:
By default, Grid places items automatically — left to right, top to bottom. No placement rules needed.
.1 { /* auto placed */ }.2 { /* auto placed */ }.3 { /* auto placed */ }.4 { /* auto placed */ }.5 { /* auto placed */ }.6 { /* auto placed */ }Grid vs Flexbox — Choosing the Right Tool
Both tools overlap, but each has a clear home territory:
A horizontal navbar with logo, links, and a CTA button
Your Challenge
Build the full coffee shop page layout using CSS Grid with named template areas.
Challenge
Build a full page layout using CSS Grid with named areas: header spanning full width, a sidebar (200px) and main content side by side, and a footer spanning full width. Use grid-template-areas to define the layout and grid-area on each element.
CSS Grid
mediumThe coffee shop needs a real page layout — header spanning the full width, sidebar for categories, main content area, and a footer. Grid makes this a 10-line CSS solution.
CSS Grid
CSS Grid is a two-dimensional layout system — it handles rows and columns simultaneously. Where Flexbox thinks in one direction at a time, Grid thinks in both at once. It's the right tool for full-page layouts, photo galleries, dashboards, and any design with a defined structure.
grid-template-columns and rows
The foundation of Grid: define your column and row tracks, then let items flow in:
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto auto;
gap: 12px;
}Placing Items on the Grid
Grid items can be placed automatically or precisely positioned using line numbers, spans, or named areas:
By default, Grid places items automatically — left to right, top to bottom. No placement rules needed.
.1 { /* auto placed */ }.2 { /* auto placed */ }.3 { /* auto placed */ }.4 { /* auto placed */ }.5 { /* auto placed */ }.6 { /* auto placed */ }Grid vs Flexbox — Choosing the Right Tool
Both tools overlap, but each has a clear home territory:
A horizontal navbar with logo, links, and a CTA button
Your Challenge
Build the full coffee shop page layout using CSS Grid with named template areas.
Challenge
Build a full page layout using CSS Grid with named areas: header spanning full width, a sidebar (200px) and main content side by side, and a footer spanning full width. Use grid-template-areas to define the layout and grid-area on each element.