D. Replace with text-center sm:text-left (no change needed)
Solution
Step 1: Understand responsive prefixes in Tailwind
Classes without prefix apply to all screen sizes. Prefixes like sm:, md: apply from that screen size and up.
Step 2: Analyze the requirement and current code
We want left alignment on small screens and center on medium and larger. The current code aligns center by default and left on small screens, which is opposite.
Step 3: Correct the classes
Use text-left for default (small screens) and md:text-center for medium and above to get the desired effect.
Final Answer:
Replace with text-left md:text-center -> Option B
Quick Check:
Default left + md center = text-left md:text-center [OK]
Hint: Default class applies to all, use md: for medium screens [OK]
Common Mistakes:
Mixing sm: and md: prefixes incorrectly
Not setting default alignment properly
Assuming sm: applies only to small screens, not up
5. You want a paragraph's text to be left aligned on mobile, center aligned on tablets, and right aligned on desktops using Tailwind. Which class combination achieves this?
hard
A. text-left md:text-center lg:text-right
B. text-center sm:text-left lg:text-right
C. text-right md:text-center sm:text-left
D. text-left sm:text-center md:text-right
Solution
Step 1: Understand Tailwind responsive prefixes
Classes without prefix apply to all screen sizes (mobile by default). md: applies from medium screens (tablets) and up, lg: applies from large screens (desktops) and up.
Step 2: Match alignment to screen sizes
We want left alignment on mobile (default), center on tablets (md), and right on desktops (lg). So the classes should be text-left, md:text-center, and lg:text-right.
Final Answer:
text-left md:text-center lg:text-right -> Option A
Quick Check:
Mobile left, tablet center, desktop right = text-left md:text-center lg:text-right [OK]
Hint: Use no prefix for mobile, md: for tablets, lg: for desktops [OK]