Challenge - 5 Problems
Responsive Utility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
Which Tailwind class will make text red on small screens but blue on medium screens?
You want the text color to be red on small screens and blue on medium screens and larger. Which class combination achieves this?
Attempts:
2 left
💡 Hint
Remember that Tailwind applies mobile-first styles, so unprefixed classes apply to all screen sizes unless overridden.
✗ Incorrect
In Tailwind, unprefixed classes apply to all screen sizes. The prefix 'md:' applies styles starting at medium screens. So 'text-red-500 md:text-blue-500' means red text on small screens and blue text on medium and larger.
❓ layout
intermediate2:00remaining
How to make a div full width on mobile but half width on large screens using Tailwind?
You want a
<div> to take full width on small screens and half the width on large screens. Which class set achieves this?Attempts:
2 left
💡 Hint
Think about mobile-first approach and how prefixes override base styles.
✗ Incorrect
The class 'w-full' sets width to 100% on all screens by default. The 'lg:w-1/2' overrides it to 50% width on large screens and above.
🧠 Conceptual
advanced2:00remaining
What happens if you use conflicting Tailwind classes without responsive prefixes?
Consider the classes
text-green-500 and text-red-500 applied together on the same element without any prefixes. What will be the text color?Attempts:
2 left
💡 Hint
CSS applies styles in order, with later rules overriding earlier ones if they have the same specificity.
✗ Incorrect
Tailwind classes generate CSS rules. When two classes set the same property, the one that appears later in the class attribute wins, so the text color will be red.
❓ accessibility
advanced2:00remaining
How to ensure responsive text size changes remain accessible in Tailwind?
You want text to be small on mobile and larger on desktop using Tailwind. Which approach best supports accessibility?
Attempts:
2 left
💡 Hint
Accessibility means respecting user settings and making text readable on all devices.
✗ Incorrect
Using relative sizes like 'text-base' and 'text-xl' helps maintain readability and respects user zoom and screen reader settings. Testing is important to ensure accessibility.
📝 Syntax
expert2:00remaining
What error occurs if you write this Tailwind class incorrectly:
md:text-lg text-base md:text-sm?Given the classes
md:text-lg text-base md:text-sm on an element, what will be the effective text size on medium screens and why?Attempts:
2 left
💡 Hint
Later classes override earlier ones if they set the same CSS property and have the same specificity.
✗ Incorrect
Both 'md:text-lg' and 'md:text-sm' apply at medium screens. Since 'md:text-sm' comes last, it overrides 'md:text-lg', so text size is small on medium screens.