Recall & Review
beginner
What does the
gap utility in Tailwind CSS do in a grid layout?The
gap utility adds space between grid cells, both horizontally and vertically, making the layout clearer and easier to read.Click to reveal answer
beginner
How do you add a 1rem gap between grid cells using Tailwind CSS?
Use the class
gap-4 because Tailwind's spacing scale sets 4 to 1rem by default.Click to reveal answer
intermediate
What is the difference between
gap-x-4 and gap-y-4 in Tailwind CSS?gap-x-4 adds horizontal space between grid columns, while gap-y-4 adds vertical space between grid rows.Click to reveal answer
intermediate
Why is it better to use Tailwind's
gap utilities instead of margin on grid items?Using
gap keeps spacing consistent and avoids collapsing margins or uneven spacing that can happen with margins on individual items.Click to reveal answer
intermediate
Can you use different gap sizes for horizontal and vertical spacing in Tailwind CSS grids?
Yes, by combining
gap-x-* and gap-y-* classes, you can set different horizontal and vertical gaps.Click to reveal answer
Which Tailwind class adds equal space between all grid cells?
✗ Incorrect
gap-4 adds equal spacing between all grid cells horizontally and vertically.How do you add only vertical spacing between grid rows in Tailwind?
✗ Incorrect
gap-y-4 adds vertical space between grid rows only.What is the default unit for Tailwind's gap utilities like
gap-4?✗ Incorrect
Tailwind's spacing scale uses
rem units by default, so gap-4 equals 1rem.Why might using margin on grid items be less ideal than using
gap?✗ Incorrect
Margins can collapse or create uneven spacing, while
gap ensures consistent space between grid cells.Which classes would you combine to have 1rem horizontal gap and 0.5rem vertical gap?
✗ Incorrect
gap-x-4 sets horizontal gap to 1rem and gap-y-2 sets vertical gap to 0.5rem.Explain how to control spacing between grid cells in Tailwind CSS and why it is useful.
Think about how <code>gap</code> works and why it is better than margins.
You got /4 concepts.
Describe how you would set different horizontal and vertical gaps in a grid using Tailwind CSS classes.
Use separate classes for horizontal and vertical gaps.
You got /4 concepts.