Align Items in Their Cells

Your work day page now has four named areas: the heading, the photo, the details, and the jobs. The details area still gives the time in a sentence, though. Volunteers who check the page on a Saturday morning want to see at a glance when and where to meet and what to bring.

Rosa would like the details set out like a paper form, labels in one column and values beside them. In this lesson, you’ll build that two-column list as a grid, then move each label inside its cell so it sits right next to its value. Start by turning the sentence into pairs.

Set Out the Details in Two Columns

HTML’s element for pairs is the description list, <dl>. Each term goes in a <dt>, followed by a <dd> that describes the term. The browser indents the <dd> below the term.

Rosa has added water and a hat to what volunteers should bring. The volunteers meet at the tool shed. In events/work-day.html, replace the date paragraph at the top of <div class="details"> with this list:

Language: HTML
<dl class="event-facts">
  <dt>When</dt>
  <dd>
    <time datetime="2026-11-28T09:00">Saturday,
      November 28, from 9 a.m.</time> to noon
  </dd>
  <dt>Where</dt>
  <dd>At the tool shed</dd>
  <dt>Bring</dt>
  <dd>
    <ul>
      <li>Gloves</li>
      <li>Water</li>
      <li>A hat</li>
    </ul>
  </dd>
</dl>

A <dd> can hold more than text, so what to bring stays a list. The <dl> now has six children: three pairs of terms and descriptions. In a two-column grid, the browser fills the cells row by row, so each label lands beside its value. Add this rule at the end of layout.css:

Language: CSS
.event-facts {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-s);
}

The labels get a third of the width, the same split as the page’s own columns. Two more rules remove the browser’s indent on each <dd> and the list’s margins and make the labels white on green, like the cards’ badges. The color also shows you where each label’s box ends. Add them below the grid rule:

Language: CSS
.event-facts dd,
.event-facts ul {
  margin: 0;
}

.event-facts dt {
  padding-inline: var(--space-s);
  border-radius: 4px;
  background-color: var(--green);
  color: white;
  font-weight: bold;
}

Save, and each label sits beside its value:

The work day details as two columns, with each label a wide green block filling the left column and as tall as its value, the Bring block running down beside a three-item list.
The Labels Stretched to Fill Their Cells

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.