Menu
CoddyTech

Disabled Controls

Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 43 of 55.

A button carrying the HTML disabled attribute matches disabled:opacity-50. The attribute prevents normal activation; the utility changes only its visual appearance.

<button disabled class="disabled:opacity-50">Unavailable</button>

A faded button is not automatically disabled. Use the semantic HTML attribute and a state variant together, and keep a readable label explaining the unavailable action.

challenge icon

Challenge

Medium

Show the disabled Sold out control at 35 percent opacity, while an enabled control should remain fully opaque.

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>
<button id="target" class="" disabled>Sold out</button><button id="target_enabled" class="">Reserve</button>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals