CSS · Unit 3: Layout with flexbox and grid · Lesson 6 of 6
Project: style an event page
Now style a whole page.
Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.
The idea
Now style a whole page. The HTML is a small event site: a header with a title and menu, then three cards.
Work in three steps, the way designers do: base styles, then layout, then polish. Each step builds on the last.
Watch the preview as you go, and use everything from this track: fonts, spacing, flexbox, grid, contrast and a media query.
Worked example
CSS
body {
font-family: system-ui, sans-serif;
}
.site {
padding: 16px;
background-color: #102a43;
color: #ffffff;
}
The HTML it styles
<header class="site">
<h1>Riverside Night Market</h1>
</header>
Key terms
- Flexbox
- display: flex lines children up in a row or column; gap spaces them.
- CSS grid
- display: grid lays children out in rows and columns at once.
- Media query
- @media (min-width: 600px) { ... } applies rules only when the screen is wide enough.
- Contrast
- How much text stands out from its background. Aim for 4.5:1 or more for normal text.
Practise it in Code Academy
This is a project lesson. It has 4 exercises (multiple choice and write code from a prompt) and takes about 15 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.
Every lesson is free: no ads, no lives and no paywall.