4. You notice inconsistent spacing on your webpage. Which Tailwind class usage is likely causing this problem?
medium
A. Using p-4 on all buttons
B. Using m-4 consistently on all elements
C. Using both p-4 and p-6 on sibling elements randomly
D. Using mt-4 only on headers
Solution
Step 1: Identify inconsistent spacing cause
Randomly mixing different padding sizes on siblings causes uneven spacing.
Step 2: Compare with consistent spacing usage
Consistent use of same spacing classes keeps layout uniform and neat.
Final Answer:
Using both p-4 and p-6 on sibling elements randomly -> Option C
Quick Check:
Mixing spacing sizes = inconsistent layout [OK]
Hint: Look for mixed spacing classes on similar elements [OK]
Common Mistakes:
Thinking any margin or padding causes inconsistency
Ignoring sibling element spacing
Assuming directional spacing causes inconsistency
5. You want to create a card layout with equal spacing between cards using Tailwind CSS. Which approach ensures consistent horizontal and vertical spacing?
hard
A. Apply mx-4 on cards and mt-2 on container
B. Apply p-4 to the container and no margin on cards
C. Apply different margin classes on cards based on their position
D. Apply m-4 to each card and use flex flex-wrap on the container
Solution
Step 1: Understand spacing between cards
Margin on cards creates space between them; consistent margin keeps spacing uniform.
Step 2: Use flex-wrap for layout
Using flex flex-wrap allows cards to wrap and maintain spacing on multiple rows.
Step 3: Avoid inconsistent spacing
Applying different margins or padding on container only won't create equal gaps between cards.
Final Answer:
Apply m-4 to each card and use flex flex-wrap on the container -> Option D