Challenge - 5 Problems
Group-hover Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
How to change child text color on parent hover?
You want the text inside a child
<p> to turn blue when the parent <div> is hovered. Which Tailwind class setup achieves this?Tailwind
<div class="group"> <p class="???">Hover me!</p> </div>
Attempts:
2 left
💡 Hint
Remember to add
group class to the parent and use group-hover: prefix on the child.✗ Incorrect
The
group-hover: prefix in Tailwind applies styles to child elements when the parent with group class is hovered. Option A correctly uses group-hover:text-blue-500 on the child <p>.❓ layout
intermediate2:00remaining
Which Tailwind setup makes child visible only on parent hover?
You want a child
<div> to be hidden normally and appear only when the parent <section> is hovered. Which option correctly uses Tailwind classes?Tailwind
<section class="group"> <div class="???">I appear on hover!</div> </section>
Attempts:
2 left
💡 Hint
Use
hidden to hide by default and group-hover:block to show on parent hover.✗ Incorrect
Option D hides the child by default with
hidden and shows it when the parent with group is hovered using group-hover:block. Other options misuse hover or group prefixes.🧠 Conceptual
advanced2:00remaining
Why does
group-hover require the parent to have group class?In Tailwind CSS, the
group-hover variant only works if the parent element has the group class. Why is this necessary?Attempts:
2 left
💡 Hint
Think about how CSS selectors work with classes and hover states.
✗ Incorrect
The
group class adds a CSS class to the parent element. Tailwind uses this class in selectors like .group:hover > .group-hover\:text-blue-500 to style children on parent hover. No JavaScript or display changes happen.❓ accessibility
advanced2:00remaining
How to keep keyboard accessibility with group-hover effects?
You use
group-hover to show a tooltip on parent hover. How can you ensure keyboard users also see the tooltip when focusing the parent?Attempts:
2 left
💡 Hint
Keyboard users navigate with focus, not hover.
✗ Incorrect
Adding
group-focus classes on the child ensures the tooltip appears when the parent is focused via keyboard. This complements group-hover for mouse users. Other options either hide the tooltip or don't support keyboard focus.❓ rendering
expert3:00remaining
What is the visual result of this Tailwind snippet?
Given this code, what color will the
<span> text show when the user hovers the <article>?Tailwind
<article class="group p-4 border"> <h2 class="text-gray-800">Title</h2> <span class="text-gray-500 group-hover:text-red-600 group-focus:text-green-600">Status</span> </article>
Attempts:
2 left
💡 Hint
Check the order and meaning of
group-hover: and group-focus: classes.✗ Incorrect
The
group-hover:text-red-600 changes the text color to red when the parent article is hovered by mouse. The group-focus:text-green-600 changes it to green when the parent is focused by keyboard. The default color is gray.