The class list has two sm: prefixed background colors: sm:bg-blue-200 and sm:bg-red-400.
Step 2: Understand conflict in overrides
Both apply at small screen sizes, but only one can take effect. The last one sm:bg-red-400 will override the first, making the first redundant or confusing.
Final Answer:
Duplicate sm: prefixes with conflicting colors -> Option D
Quick Check:
Duplicate prefixes cause override conflicts [OK]
Hint: Avoid repeating same prefix with different utilities [OK]
Common Mistakes:
Ignoring duplicate prefixes
Thinking multiple same prefixes combine
Assuming missing colon error
5. You want a button that is green on small screens, yellow on medium, and red on large screens. Which Tailwind class list achieves this correctly?
hard
A. bg-green-500 md:bg-yellow-500 lg:bg-red-500
B. bg-green-500 lg:bg-yellow-500 md:bg-red-500
C. md:bg-green-500 bg-yellow-500 lg:bg-red-500
D. lg:bg-green-500 md:bg-yellow-500 bg-red-500
Solution
Step 1: Assign base color for smallest screens
Base utility without prefix applies to all screens by default, so bg-green-500 sets green on small screens.
Step 2: Override colors for medium and large screens
md:bg-yellow-500 applies yellow from medium screens up, and lg:bg-red-500 applies red from large screens up, overriding previous colors.
Step 3: Check order and prefixes
The order and prefixes in bg-green-500 md:bg-yellow-500 lg:bg-red-500 correctly apply colors in increasing screen sizes.
Final Answer:
bg-green-500 md:bg-yellow-500 lg:bg-red-500 -> Option A