Lesson 16 of 3053%

(Progress persistence is disabled until Phase 9)

Tailwind CSS
Beginner

Space Between Elements

Using the space-x and space-y utilities.

When you have a group of elements, applying margins to each child can be tedious.

The space-x-{size} and space-y-{size} utilities add margin between child elements automatically.

<div class="space-y-4">
  <div class="bg-white p-4">Item 1</div>
  <div class="bg-white p-4">Item 2</div>
  <div class="bg-white p-4">Item 3</div>
</div>

(This adds a top margin only to Item 2 and Item 3)

Try It Yourself

Lesson Progress

Take QuizBuild a Tailwind CSS Project