0
0
Tailwindmarkup~20 mins

Space between children (space-x, space-y) in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Spacing Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding space-x in Tailwind CSS
What visual effect does the class space-x-4 have on a container with multiple inline children?
AAdds horizontal space of 1rem between each child element.
BAdds vertical space of 1rem between each child element.
CAdds horizontal padding of 1rem inside each child element.
DAdds margin of 1rem around the entire container.
Attempts:
2 left
💡 Hint
Think about the direction of the space when using space-x.
📝 Syntax
intermediate
1:00remaining
Correct usage of space-y for vertical spacing
Which Tailwind CSS class correctly adds vertical space of 0.5rem between stacked children?
Aspace-vertical-2
Bspace-x-2
Cspace-y-0.5
Dspace-y-2
Attempts:
2 left
💡 Hint
Remember the naming pattern for vertical spacing in Tailwind.
rendering
advanced
2:00remaining
Visual result of combining space-x and space-y
Given a flex container with classes flex flex-wrap space-x-3 space-y-6, what spacing will the children have?
Tailwind
<div class="flex flex-wrap space-x-3 space-y-6">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
  <div>Item 4</div>
</div>
AChildren have 0.75rem horizontal and 1.5rem vertical space between them, wrapping to new lines as needed.
BChildren have 3rem horizontal and 6rem vertical space between them, no wrapping.
CChildren have 0.75rem vertical and 1.5rem horizontal space, wrapping disabled.
DChildren have no space between them because <code>space-x</code> and <code>space-y</code> cannot be combined.
Attempts:
2 left
💡 Hint
Check the spacing scale: 3 means 0.75rem, 6 means 1.5rem.
selector
advanced
1:30remaining
How does Tailwind apply space-x spacing in CSS?
Which CSS selector does Tailwind use internally to apply horizontal spacing with space-x-4?
ALast child selector: *:last-child { margin-left: 1rem; }
BAll children selector: * { margin-left: 1rem; }
CDirect child selector with adjacent sibling combinator: > * + * { margin-left: 1rem; }
DFirst child selector: *:first-child { margin-left: 1rem; }
Attempts:
2 left
💡 Hint
Think about how spacing is added only between siblings, not before the first child.
accessibility
expert
2:30remaining
Accessibility considerations when using space-x and space-y
When using space-x or space-y for spacing between interactive elements, what accessibility best practice should you follow?
AUse <code>aria-hidden</code> on all children to avoid confusion.
BEnsure the spacing does not reduce the clickable area or cause elements to be too close for keyboard navigation.
CRemove all spacing on focus states to avoid layout shifts.
DAdd tabindex="-1" to all children to prevent keyboard focus.
Attempts:
2 left
💡 Hint
Think about how spacing affects users who navigate with keyboard or touch.