The garden’s website has its pages, colors, and type, but every box still stacks in one centered column. Rosa would like the menu beside the garden’s name, the spring events side by side, and a sidebar on the home page. Arranging boxes like that is layout, and it’s what this course is about.
Every layout tool in CSS starts from one rule that tends to surprise programmers. In this lesson, you’ll try to put the event cards in a row, find out which element a layout belongs on, and learn to predict which boxes move. Start by getting the garden’s site in front of you.
Set Up the Garden Site
Over this course, you’ll lay out the garden’s site at desktop width, from the header to a card grid and a sidebar. Adapting the site for phones is the next step on the path.
You’ll use only HTML and CSS, building on the box model and on block and inline boxes. Type the CSS rather than pasting it. When a box doesn’t move as you expect, check the Styles and Computed panes in DevTools for clues. Each section ends with exercises, and a project lays out the whole site.
Skip any step you’ve already done:
- Get a current version of Chrome or Edge.
- Install VS Code, then install Live Preview by Microsoft from its Extensions view, which you open with Ctrl+Shift+X or Cmd+Shift+X on macOS.
- Download and unzip the course’s sample code ZIP file and copy its
01-parent-arranges/garden/folder to where you keep your projects. - If
garden/images/is empty, copy in the six photos fromgarden-photos.zip, in the course’s supporting materials. - Open the
garden/folder in VS Code using File → Open Folder, then openevents/upcoming.html. - Open the Command Palette with Ctrl+Shift+P, or Cmd+Shift+P on macOS, and run Live Preview: Show Preview (External Browser). If another browser opens, paste its address into Chrome or Edge.
The starter is the garden’s finished design with style.css unchanged, plus content to lay out. Each new block sits under a New in this course comment:
volunteers.html: A new page with six volunteer profiles, each with a photo and a paragraphindex.html: The page’s content wrapped in<div class="home-intro">, followed by a volunteer-of-the-month<aside>about Tomás, ending in a link to the new volunteers pageplots.html: A plot map above the table, with the beds, paths, tool shed, and compostevents/upcoming.html: A banner around the<h1>, a wrapper around the cards, the spring season’s seven events, and a seed swap news<aside>at the bottomevents/work-day.html: A sign-up notice with a round photo, outside the event cardevents/seed-swap.html: A banner around the<h1>and a How to swap block
Switching to the starter is simpler, and it’s what the screenshots show. To keep your own folder instead, copy in volunteers.html, then copy every marked block from these pages into yours, wrappers included.
On the events page, the seven .event-card articles in Coming Up now sit in a new <div>:
<section>
<h2>Coming Up</h2>
<!-- New in this course: the cards' wrapper,
with the spring season's seven events -->
<div class="event-list">
<article class="event-card">
<h3>Clear the Beds</h3>
<p>
<time datetime="2027-03-06T09:00">Saturday,
March 6, from 9 a.m.</time> to noon.
<a href="work-day.html">The work day's jobs</a>
</p>
</article>
<!-- ... -->
</div>
</section>
The <div class="event-list"> doesn’t change the page’s look. It groups the cards so CSS can arrange them as one set.
You’ll try layouts in a practice stylesheet, leaving style.css alone until the project. Create events/layout.css:
events/layout.css
/* Layouts to try on the events pages */
Link it in the <head> of upcoming.html, work-day.html, and seed-swap.html, right after style.css:
<link rel="stylesheet" href="../style.css">
<link rel="stylesheet" href="layout.css">
The rules in style.css sit in cascade layers, and those in layout.css don’t. A normal declaration outside any layer overrides a competing one inside a layer, whatever their specificity. Only a layered !important declaration would beat it, and style.css has none, so your layout.css rules win.
Save and go back to the upcoming.html preview from step 6, at whatever address it shows, such as http://127.0.0.1:3000/events/upcoming.html. Scroll to Coming Up:

The cards stack, each as wide as the column. That’s normal flow, the layout every page starts with. Each card is a block box, so it starts on a new line and fills its parent’s width. Rosa wants them side by side, so visitors see the spring at a glance.
Put the Cards Side by Side
To arrange boxes, you change a property you’ve met, display. Its value flex switches on flexbox, one of this course’s two layout tools, which puts boxes in a row. That’s all you need about flexbox for now.
The cards should sit side by side, so the natural place for the rule is the cards. Add it to layout.css, below the comment:
events/layout.css
/* Layouts to try on the events pages */
.event-card {
display: flex;
}
Before you save, decide: Will the seven cards sit in one row? Commit to an answer, then save and look.
The cards still stack. What changed is inside each card:

Inside each card, the heading and the date line now sit side by side. That was a detour, and a common one. The rule did what it says. display: flex makes an element arrange its own children in a row, and it doesn’t move the element itself. The cards stayed where normal flow put them.
There’s no error to report. If you’ve placed things on a screen in code, you may expect each element to position itself. In CSS, an element’s parent arranges it along with its siblings. Each card stayed a block among the cards, so they still stack.
The display property sets two things. Its outside value decides how the box sits among its siblings: a block box starts on a new line, while an inline box sits in a line of text. Its inside value decides how the box lays out its children: in normal flow, as a flex row, or in a grid, the course’s other layout tool.
So display: block means block outside, flow inside, and display: flex means block outside, flex inside, written in full as block flex on MDN’s display page.
An element with display: flex is a flex container, and its children are its flex items.
To check in DevTools, select an <article class="event-card"> in the Elements panel and filter the Computed pane for display, which shows flex. Then select the card’s <h3>, which still shows block. The heading is a flex item because of the card’s display.
If the parent doing the arranging still feels backward, the button below opens a chat with the mentor and fills in the question:
Move the Layout to the Parent
The cards should be flex items, so display: flex belongs on their parent, the <div class="event-list"> that wraps them. The <section> would be wrong, because its children are the Coming Up heading and the list, so the heading would join the row. That’s why the starter gives the cards a wrapper.
In layout.css, change the selector to .event-list:
events/layout.css
/* Layouts to try on the events pages */
.event-list {
display: flex;
}
Save, and the cards line up:

Each card’s heading is back above its date, because the card has flow inside again. Seven cards are too many for one row, so some words break across lines. Sizing and wrapping come later. For now, look at which boxes moved.
The rule reached exactly one level down the tree. The cards, the list’s children, became flex items. Their headings and dates, the list’s grandchildren, are in normal flow. The Coming Up heading, outside the list, didn’t change. Here’s that part of the page’s tree:
Leave the .event-list rule in layout.css.
Work Out Which Boxes Move
To tell what a display: flex rule will move, find the element it’s on and list its children. Only they become flex items. Here’s the method on two more elements.
Start with <main>. Its children are the page’s three big blocks:
<main>
<div class="events-banner">
<h1>Upcoming Events</h1>
<p>Everyone's welcome, with or without a plot.</p>
</div>
<section>
<!-- Coming Up and its cards -->
</section>
<aside class="swap-news">
<!-- Seed Swap News -->
</aside>
</main>
With display: flex on main, the banner, the Coming Up section, and the seed swap news would sit side by side as three flex items. The <h1> is inside the banner, a grandchild of <main>, so it stays in normal flow.
You might expect display: flex on the menu’s .site-nav to line up the four links, but look at what’s directly inside the <nav>:
<nav class="site-nav">
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="../plots.html">Plots</a></li>
<!-- About and Events -->
</ul>
</nav>
The <nav> has one child, the <ul>, so the list is its only flex item and the links stay stacked. The links sit in the <li> elements, the children of the <ul>. For a row of links, display: flex goes on the <ul>.
Test either rule in layout.css if you like, then put the file back to its .event-list rule. Try these two before you open the answers:
- Explain why
display: flexon.event-cardleft the cards stacked. - Explain why
display: flexon the Coming Up<section>would be the wrong fix for the cards.
display: flexarranges an element’s own children, so each card’s heading and date became flex items. The cards’ parent,.event-list, still had flow inside.- The
<section>has two children, the Coming Up heading and the.event-list. Both would become flex items, so the heading would sit beside the list instead of above it.
To practice predicting which boxes move on the garden’s pages, use the button below to start a short quiz with the mentor:
A layout goes on the parent and reaches its direct children. Which layout to put there is the next question. In the next lesson, Choose Flow, Flexbox or Grid, you’ll watch the same cards laid out by flexbox and by grid as the window narrows.