Lesson 28 of 3093%

(Progress persistence is disabled until Phase 9)

Tailwind CSS
Beginner

Hover and Focus States

Styling elements on interaction.

You can apply classes conditionally when an element is hovered or focused using prefixes.

  • hover:
  • focus:
<button class="bg-blue-500 hover:bg-blue-700 text-white px-4 py-2 rounded transition-colors">
  Hover me
</button>

Tip: Using transition-colors makes the background change smoothly!

Try It Yourself

Lesson Progress

Ready to practise?

Apply what you learned with a hands-on challenge.

Practise This Topic