Skip to content

Grid Layout

You'll build a magazine-style page with CSS Grid and no framework, with a header, a sidebar, a gallery and a footer that all stack neatly on a phone.

About

Flexbox is for rows, and Grid is for pages. Once you can place things in two dimensions by name, you stop needing a column framework and start designing. You'll build one page that uses Grid properly, with a header, a sidebar, a main column, a gallery and a footer, all of it shifting to a single column at phone width without a single float. The last requirement checks that the keyboard order still matches what's on screen, which Grid makes easy to get wrong.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
Three weeks
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Web Building to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Sketch the layout on paper at desktop width and at phone width. Draw two boxes and label the areas: header, nav, main, aside and footer. This sketch is the plan your grid-template-areas will copy. Take a photo of the sketch. Photo
  2. 2
    Build the page shell with grid-template-areas. Name each area in CSS exactly as you sketched it, and use gap instead of margins between the regions. Take a screenshot of the page with the Grid overlay turned on in dev tools. Photo
  3. 3
    Make a gallery with auto-fill and minmax. Build a row of cards or images that reflows from four columns down to one with no media query at all, using grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)). Film yourself resizing the window and watching it reflow. Video
  4. 4
    Change the layout at phone width with one media query. Rewrite grid-template-areas for narrow screens so everything stacks in reading order. Take one screenshot showing the page at 375px and at 1200px side by side. Photo
  5. 5
    Use Flexbox for one row inside the grid. The nav or the footer links are the natural place. Use justify, align and wrap, and notice which tool is for which job. Take a screenshot of the nav with the Flexbox overlay on. Photo
  6. 6
    Check that the tab order matches the visual order. Grid can put things on screen in a different order from the source, and keyboards follow the source. Tab through the page, and if the focus jumps around, fix the source order rather than the CSS. Film yourself tabbing through the page. Video