0
0
Tailwindmarkup~20 mins

Active variant in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Active Variant Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
What color will the button text be when clicked?

Consider this Tailwind CSS button:

<button class="text-black active:text-red-500">Click me</button>

What color will the button text have while the mouse button is held down on it?

Tailwind
<button class="text-black active:text-red-500">Click me</button>
AThe text color changes to red while the button is pressed.
BThe text color stays black even when the button is pressed.
CThe text color changes to red only after the button is released.
DThe text color changes to red when hovered, not when pressed.
Attempts:
2 left
💡 Hint

Think about what the active: variant does in Tailwind CSS.

🧠 Conceptual
intermediate
1:30remaining
When does the active: variant apply styles?

Choose the correct description of when Tailwind's active: variant styles are applied.

AWhile the element is being clicked (mouse button held down).
BWhen the element is focused by keyboard navigation.
CWhen the mouse pointer is hovering over the element.
DAfter the element has been clicked and released.
Attempts:
2 left
💡 Hint

Think about the difference between hover, focus, and active states.

rendering
advanced
2:00remaining
What happens to the button background color on active state?

Given this button:

<button class="bg-blue-500 active:bg-green-500 text-white p-3 rounded">Press me</button>

What background color will the button show while it is being pressed?

Tailwind
<button class="bg-blue-500 active:bg-green-500 text-white p-3 rounded">Press me</button>
AThe background color stays blue even when pressed.
BThe background color changes to green while pressed.
CThe background color changes to green only after releasing the button.
DThe background color changes to blue on hover, not active.
Attempts:
2 left
💡 Hint

Remember how active: modifies styles during pressing.

accessibility
advanced
2:00remaining
Which is true about keyboard accessibility and active: styles?

Consider a button styled with Tailwind's active: variant. Which statement about keyboard users is correct?

AThe <code>active:</code> styles apply only when the button is focused, not activated.
BThe <code>active:</code> styles only apply on mouse clicks, not keyboard activation.
CKeyboard users never see <code>active:</code> styles because they only respond to hover.
DThe <code>active:</code> styles apply when the button is activated via keyboard (e.g., space or enter).
Attempts:
2 left
💡 Hint

Think about how browsers handle :active state for keyboard activation.

📝 Syntax
expert
2:30remaining
Which Tailwind class correctly applies a red border only when the button is active?

Choose the correct Tailwind class to add a red border only while the button is pressed.

Tailwind
<button class="border-2 ???">Press me</button>
Aborder-red-500 active
Bhover:border-red-500 active
Cactive:border-red-500
Dactive:border: red-500
Attempts:
2 left
💡 Hint

Remember the correct syntax for Tailwind variants.