0
0
Tailwindmarkup~20 mins

Divide utilities between children in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tailwind Spacing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
How does space-x-4 affect child elements?
Given a parent container with space-x-4 in Tailwind CSS, what visual effect will the children have?
Tailwind
<div class="flex space-x-4">
  <div class="bg-blue-500 p-4">Child 1</div>
  <div class="bg-green-500 p-4">Child 2</div>
  <div class="bg-red-500 p-4">Child 3</div>
</div>
AChildren will overlap horizontally with no gap.
BEach child will have a 1rem vertical gap between them.
CEach child will have a 1rem horizontal gap between them.
DEach child will have a 4px horizontal gap between them.
Attempts:
2 left
💡 Hint
Think about what space-x-4 means in Tailwind's spacing scale.
selector
intermediate
2:00remaining
Which Tailwind utility divides children vertically with equal spacing?
You want to stack children vertically with equal space between them inside a parent. Which utility achieves this?
Tailwind
<div class="???">
  <div>Child 1</div>
  <div>Child 2</div>
  <div>Child 3</div>
</div>
Agrid grid-cols-3 gap-x-6
Bflex flex-col space-y-6
Cflex space-x-6
Dblock space-x-6
Attempts:
2 left
💡 Hint
Consider the direction of stacking and the spacing utility for vertical gaps.
🧠 Conceptual
advanced
2:00remaining
What happens if you apply space-x-4 to a non-flex container?
Consider this HTML:
One Two Three
What is the visual effect on the children?
Tailwind
<div class="space-x-4">
  <span>One</span>
  <span>Two</span>
  <span>Three</span>
</div>
AChildren get 1rem horizontal margin between them regardless of container display.
BNo horizontal spacing is added between children because <code>space-x-4</code> requires a flex or grid container.
CChildren stack vertically with 1rem vertical spacing.
DChildren overlap horizontally with no spacing.
Attempts:
2 left
💡 Hint
Think about how Tailwind's space utilities work internally.
accessibility
advanced
2:00remaining
How to maintain keyboard focus order when using space-x-4?
You have a horizontal list of buttons spaced with space-x-4. What should you ensure for good keyboard navigation?
Tailwind
<div class="flex space-x-4" role="group" aria-label="Options">
  <button>Option 1</button>
  <button>Option 2</button>
  <button>Option 3</button>
</div>
AWrap each button in a <code>label</code> to improve focus.
BAdd <code>tabindex="-1"</code> to all buttons except the first to skip them.
CUse JavaScript to reorder focus because <code>space-x-4</code> changes visual order but not DOM order.
DEnsure the buttons are in the correct DOM order; <code>space-x-4</code> does not affect focus order.
Attempts:
2 left
💡 Hint
Focus order follows DOM order, not visual spacing.
📝 Syntax
expert
3:00remaining
What is the correct Tailwind utility to divide children with a 2rem gap horizontally and 1rem vertically?
You want a container that spaces children with 2rem horizontally and 1rem vertically. Which utility combination is correct?
Tailwind
<div class="???">
  <div>Child A</div>
  <div>Child B</div>
  <div>Child C</div>
</div>
Aflex flex-wrap gap-x-8 gap-y-4
Bgrid grid-cols-3 gap-8 gap-4
Cflex space-x-8 space-y-4
Dflex flex-col space-x-8 space-y-4
Attempts:
2 left
💡 Hint
Use the gap utilities for both horizontal and vertical spacing in flex wrap layout.