4. Identify the error in this Tailwind class usage:
<div class="pt-3 pl-5 pb-2 px-4">Content</div>
medium
A. The class pt-3 is invalid and causes an error
B. Using both pl-5 and px-4 causes conflicting horizontal padding
C. Padding bottom pb-2 cannot be combined with px-4
D. No error; all classes combine correctly
Solution
Step 1: Analyze horizontal padding classes
pl-5 adds padding-left 1.25rem, px-4 adds padding-left and right 1rem. These overlap and conflict on left padding.
Step 2: Understand conflict effect
Because px-4 sets left padding to 1rem, it overrides pl-5 on the left side, causing confusion or unexpected padding.
Final Answer:
Using both pl-5 and px-4 causes conflicting horizontal padding -> Option B
Quick Check:
Don't combine specific side and axis padding on same side [OK]
Hint: Avoid mixing side-specific and axis padding on same side [OK]
Common Mistakes:
Thinking pt-3 is invalid
Believing pb-2 conflicts with px-4
Assuming no conflict when combining pl- and px-
5. You want to add padding so that the top and bottom have 2rem, and left and right have 1rem inside a div. Which Tailwind classes achieve this correctly?
hard
A. pt-8 pb-8 pl-4 pr-4
B. p-4 px-8
C. py-4 px-8
D. py-8 p-4
Solution
Step 1: Understand spacing scale for rem values
In Tailwind, 1rem = 4 units, so 2rem = 8 units, 1rem = 4 units.
Step 2: Match padding classes to desired sizes
pt-8 and pb-8 add 2rem padding top and bottom; pl-4 and pr-4 add 1rem padding left and right.
Step 3: Check other options
py-8 p-4 conflicts because p-4 overrides vertical padding to 1rem; p-4 px-8 results in top/bottom 1rem and left/right 2rem; py-4 px-8 reverses sizes.
Final Answer:
pt-8 pb-8 pl-4 pr-4 -> Option A
Quick Check:
Use side-specific classes for precise padding [OK]
Hint: Use pt/pb for vertical, pl/pr for horizontal precise padding [OK]