A row of buttons

Space a row of buttons evenly.

What to build

A flex row.

Requirements

  • .row is a flex container.
  • Items have a gap of 12px.
  • Items are spread with space-between.

Constraints

Do not put margins on the buttons.

Example

.row { display: flex; }

Why it works

The container controls how its children share the row, so that the children need no rules of their own.

Hints

Hint 1

display: flex goes on the parent.

Hint 2

gap adds space between the items.

Solution

Show one correct solution (try it yourself first)
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Row</title>
  <style>
    .row {
      display: flex;
      gap: 12px;
      justify-content: space-between;
    }
  </style>
</head>
<body>
  <div class="row">
    <button>Back</button>
    <button>Save</button>
    <button>Next</button>
  </div>
</body>
</html>

Lesson: Flexbox: laying things out in a line →