0
0
Tailwindmarkup~20 mins

Opacity modifiers on colors in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Opacity Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Using opacity modifiers in Tailwind CSS
Which Tailwind CSS class correctly applies a blue background color with 50% opacity?
Abg-opacity-50-blue-500
Bbg-blue-500/50
Cbg-blue-500 opacity-50
Dbg-blue-500 opacity50
Attempts:
2 left
💡 Hint
Tailwind uses a slash (/) to add opacity to colors.
rendering
intermediate
2:00remaining
Visual effect of opacity modifiers
What will you see if you apply the class bg-red-600/30 to a div with white text on a black background?
Tailwind
<div class="bg-red-600/30 text-white p-4">Hello</div>
AWhite background with red text
BSolid red background with white text on black
CBlack background with white text, no red visible
DA semi-transparent red background behind white text on black
Attempts:
2 left
💡 Hint
Opacity modifies the background color transparency, not the text color.
🧠 Conceptual
advanced
2:00remaining
Difference between opacity utilities and opacity modifiers on colors
Which statement correctly explains the difference between opacity-50 and bg-blue-500/50 in Tailwind CSS?
A<code>opacity-50</code> sets the opacity of the entire element including text, while <code>bg-blue-500/50</code> sets only the background color opacity.
B<code>opacity-50</code> sets background color opacity, <code>bg-blue-500/50</code> sets text opacity.
C<code>opacity-50</code> sets text color opacity, <code>bg-blue-500/50</code> sets border opacity.
DBoth classes do the same thing and can be used interchangeably.
Attempts:
2 left
💡 Hint
Think about what parts of the element each class affects.
selector
advanced
2:00remaining
Selecting elements with opacity modifiers in Tailwind
Given this HTML, which CSS selector targets only elements with a background color opacity of 40% using Tailwind's opacity modifier syntax?
Tailwind
<div class="bg-green-400/40">Green</div>
<div class="bg-green-400/50">Green</div>
<div class="bg-green-400">Green</div>
A[class*='bg-green-400/40']
B.bg-green-400-40
C.bg-green-400\/40
D[class='bg-green-400/40']
Attempts:
2 left
💡 Hint
Remember how special characters like slash are escaped in CSS selectors.
accessibility
expert
2:00remaining
Accessibility considerations with opacity modifiers on colors
Why should you be careful when using low opacity background colors like bg-gray-900/10 behind text in Tailwind CSS?
ALow opacity backgrounds can reduce contrast, making text hard to read for users with visual impairments.
BLow opacity backgrounds increase page load time significantly.
CLow opacity backgrounds disable keyboard navigation on the element.
DLow opacity backgrounds cause screen readers to ignore the text.
Attempts:
2 left
💡 Hint
Think about how opacity affects color contrast and readability.