Coding⏱️ 1 min read📅 2026-06-03

How to Fix: Hover and Active only when not disabled

Learn how to apply hover and active styles only on enabled buttons.

Quick Answer: Use CSS :not() pseudo-class to target disabled elements.

To apply hover and active styles only on enabled buttons, you can add a CSS pseudo-class to your button elements. Add the following code to your stylesheet:

🔧 Proven Troubleshooting Steps

Method 1: Add the :not(:disabled) Pseudo-class

  1. Step 1: Add the following CSS code to your stylesheet:
button:hover, button:active { background-color: #ccc; } 
button:not(:disabled):hover, button:not(:disabled):active { background-color: #666; }

✨ Wrapping Up

By adding the :not(:disabled) pseudo-class, you can apply hover and active styles only to enabled buttons.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions