Hover Feedback
Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 41 of 55.
A button with opacity-100 hover:opacity-50 is fully opaque until a hover-capable pointer moves over it, when it becomes half opaque. The state prefix limits when the utility applies.
<div class="hover:opacity-50">Museum sample</div>Tailwind 4 hover variants use a hover-capable media condition, so a touch-only device may not apply them. Keep the action understandable without hover, and provide a visible keyboard focus treatment independently.
Challenge
MediumKeep the Preview button at 75 percent opacity normally and 30 percent while hovered. Its label must remain Preview.
Keep the supplied content and element IDs. Edit the HTML utility classes or the requested CSS. Click Run preview to refresh the preview after edits, then use Check/Run code to grade your work.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Practice studio</title><link rel="stylesheet" href="./styles.css"></head><body>
<div aria-hidden="true" class="h-8"></div><button id="target" class="">Preview</button>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
1Meet Tailwind
A Styled First RunChoosing UtilitiesCombining UtilitiesThe Local StylesheetRecap: Meet Tailwind9Interaction States
Hover FeedbackFocus FeedbackDisabled ControlsParent State GroupsRecap: Interaction States