0
0
Tailwindmarkup~20 mins

Group-hover (parent triggers child) in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Group-hover Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2: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>
Ap class="group-hover:text-blue-500"
Bp class="text-blue-500 group-hover"
Cp class="hover:group-hover:text-blue-500"
Dp class="group-hover-hover:text-blue-500"
Attempts:
2 left
💡 Hint
Remember to add group class to the parent and use group-hover: prefix on the child.
layout
intermediate
2: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>
Ahidden hover:block
Bblock hover:group:block
Cgroup-hidden group-hover:block
Dhidden group-hover:block
Attempts:
2 left
💡 Hint
Use hidden to hide by default and group-hover:block to show on parent hover.
🧠 Conceptual
advanced
2: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?
ABecause <code>group</code> changes the display property of the parent to flex.
BBecause <code>group</code> adds JavaScript to detect hover on the parent.
CBecause <code>group</code> sets a CSS class that enables child selectors for hover states.
DBecause <code>group</code> disables pointer events on the parent.
Attempts:
2 left
💡 Hint
Think about how CSS selectors work with classes and hover states.
accessibility
advanced
2: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?
AAdd <code>group-focus</code> classes on the child along with <code>group-hover</code>.
BAdd <code>tabindex="-1"</code> to the child element.
CUse only <code>hover</code> classes on the child, no group classes.
DAdd <code>aria-hidden="true"</code> to the tooltip.
Attempts:
2 left
💡 Hint
Keyboard users navigate with focus, not hover.
rendering
expert
3: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>
AThe <code>span</code> text turns red on hover and stays gray on focus.
BThe <code>span</code> text turns red on mouse hover and green on keyboard focus of the article.
CThe <code>span</code> text stays gray on hover and focus.
DThe <code>span</code> text turns green on mouse hover and red on keyboard focus of the article.
Attempts:
2 left
💡 Hint
Check the order and meaning of group-hover: and group-focus: classes.