Step 1: Understand the base and responsive classes
The class bg-red-500 applies red background always. The sm:bg-green-500 applies green background only on small screens and larger.
Step 2: Determine screen size effect
On screens smaller than the small breakpoint, only bg-red-500 applies, so background is red.
Final Answer:
Red background -> Option D
Quick Check:
Below sm breakpoint = base class applies [OK]
Hint: Base class applies below sm breakpoint [OK]
Common Mistakes:
Assuming sm: applies on all screens
Ignoring base class color
Thinking no color applies on small screens
4. Identify the error in this Tailwind usage for responsive padding:
<div class="p-4 md:p-8 sm:p-6">Content</div>
medium
A. Order of responsive prefixes is incorrect
B. Padding values are invalid
C. Missing base padding class
D. No error, code is correct
Solution
Step 1: Recall Tailwind responsive CSS generation
Tailwind generates media queries in breakpoint order (sm then md etc.), ensuring larger breakpoints override smaller ones regardless of HTML class order.
Step 2: Verify the behavior
Classes should be ordered from smallest to largest breakpoint to avoid confusion: base, sm:, md:. The given order p-4 md:p-8 sm:p-6 is incorrect because sm:p-6 comes after md:p-8, which can cause unexpected overrides.
Final Answer:
Order of responsive prefixes is incorrect -> Option A
Quick Check:
Responsive prefixes should be ordered sm: then md: [OK]
Hint: Tailwind responsive prefixes should be ordered from smallest to largest breakpoint [OK]
Common Mistakes:
Assuming padding values like p-6 are invalid
Believing base padding is missing
Thinking class order breaks responsive behavior
5. You want a button to have a blue background on mobile, green on tablets, and red on desktops using Tailwind. Which class list achieves this correctly?
<button class="?">Click me</button>
hard
A. bg-blue-500 md:bg-green-500 sm:bg-red-500
B. bg-blue-500 sm:bg-green-500 md:bg-red-500
C. sm:bg-blue-500 bg-green-500 md:bg-red-500
D. md:bg-blue-500 sm:bg-green-500 bg-red-500
Solution
Step 1: Match breakpoints to devices
Mobile uses base styles, tablets start at sm:, desktops start at md:.
Step 2: Assign colors in correct order
Base (mobile) = blue, sm (tablet) = green, md (desktop) = red. So classes must be bg-blue-500 sm:bg-green-500 md:bg-red-500.
Final Answer:
bg-blue-500 sm:bg-green-500 md:bg-red-500 -> Option B
Quick Check:
Base = mobile, sm = tablet, md = desktop [OK]
Hint: Base = mobile, then sm:, then md: for larger screens [OK]
Common Mistakes:
Mixing breakpoint order
Assigning wrong colors to breakpoints
Using sm: or md: incorrectly as base
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.