0
0
Tailwindmarkup~20 mins

Background color utilities in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Background Color Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
Which Tailwind class sets a blue background with 50% opacity?
You want to apply a blue background color that is half transparent. Which class will do this correctly?
Abg-blue-500 bg-opacity-50
Bbg-blue-500 opacity-50
Cbg-opacity-50 bg-blue-500
Dopacity-50 bg-blue-500
Attempts:
2 left
💡 Hint
Remember that background opacity is controlled by a separate utility in Tailwind.
rendering
intermediate
2:00remaining
What background color will this Tailwind class produce?
Given the class bg-gradient-to-r from-red-400 via-yellow-300 to-green-500, what will the background look like?
Tailwind
<div class="bg-gradient-to-r from-red-400 via-yellow-300 to-green-500 h-24 w-full"></div>
AA solid red background
BA horizontal gradient from red to yellow to green
CA vertical gradient from red to yellow to green
DA horizontal gradient from green to yellow to red
Attempts:
2 left
💡 Hint
The to-r means the gradient goes to the right (horizontal).
🧠 Conceptual
advanced
2:00remaining
Why should you prefer bg-opacity over opacity for background transparency?
Consider you want only the background color to be transparent but keep text fully visible. Which is the best reason to use bg-opacity instead of opacity?
A<code>bg-opacity</code> changes only background transparency, <code>opacity</code> affects the whole element including text and children
B<code>opacity</code> cannot be combined with background colors
C<code>bg-opacity</code> is faster to load in browsers
D<code>opacity</code> only works on images, not backgrounds
Attempts:
2 left
💡 Hint
Think about what parts of the element you want to see clearly.
layout
advanced
2:00remaining
How to make a full-screen background color with Tailwind?
You want a background color that covers the entire browser window, even if the content is small. Which combination of classes achieves this?
Aw-full h-full bg-blue-200
Bh-full bg-blue-200
Cmin-h-screen bg-blue-200
Dmax-h-screen bg-blue-200
Attempts:
2 left
💡 Hint
Think about minimum height to fill the screen regardless of content size.
accessibility
expert
2:00remaining
Which Tailwind background color utility best supports accessibility for text readability?
You want to ensure your background color provides enough contrast for text to be easily readable by all users. Which Tailwind background color class is best to use with white text for accessibility?
Tailwind
<div class="bg-??? text-white p-4">Accessible Text</div>
Abg-blue-100
Bbg-yellow-200
Cbg-pink-300
Dbg-gray-900
Attempts:
2 left
💡 Hint
Dark backgrounds with light text usually have better contrast.