The :active pseudo-class styles an element while the user is pressing or tapping it. It is one of the easiest ways to give buttons and links instant visual feedback.
01
Press feedback
Style clicks and taps.
02
Syntax
element:active
03
Buttons & links
Most common targets.
04
:hover combo
Layer interaction states.
05
Short duration
Only while pressed.
06
UX polish
Make UI feel responsive.
Fundamentals
Introduction
The :active selector in CSS is used to style an element when it is being activated by the user. This typically happens when someone clicks a button, taps a link, or presses a form control.
The :active pseudo-class applies styles only during the interaction itself, giving users clear visual feedback that their action was received.
Definition and Usage
Use :active on interactive elements such as <button>, <a>, and <input> to darken a background, shrink an element slightly, or change color while pressed. The effect disappears as soon as the user releases the mouse button or lifts their finger.
💡
Beginner Tip
:active is not the same as :hover. Hover means the pointer is resting on the element; active means the user is currently pressing it. Use both together for polished buttons.
Foundation
📝 Syntax
The syntax for the :active pseudo-class is straightforward:
When both :hover and :active match, the rule that appears later in the stylesheet wins if specificity is equal. Putting :active last keeps the pressed color visible.
Example 4 — Press-down button effect
Use transform and box-shadow together to simulate a physical button press.
The shadow creates depth. On :active, the button shifts down and the shadow shrinks, mimicking a real press.
Watch Out
⚠️ Common Pitfalls
Short duration — :active lasts only while the mouse or finger is down. Test by clicking and holding, not just clicking quickly.
Order matters — If :hover is declared after :active with the same specificity, hover can override the pressed look while the pointer is still over the element.
Non-interactive elements — :active on a plain div only works if you add interaction (for example tabindex="0" or JavaScript handlers).
Overdoing motion — Large scale or movement changes can feel jarring. Subtle shifts work best.
A11y
♿ Accessibility
Do not rely on color alone — Pair color changes with size, shadow, or outline so low-vision users notice the state.
Keep :focus visible — :active is not a replacement for keyboard focus styles. Always style :focus or :focus-visible too.
Avoid removing outlines — Never use outline: none without providing an accessible alternative.
Respect reduced motion — Consider @media (prefers-reduced-motion: reduce) for large transforms on press.
🧠 How :active Works
1
User presses an element
A mouse click, tap, or keyboard activation starts the interaction.
Input
2
Browser matches :active
While the press continues, the element matches the :active pseudo-class.
Match
3
Active styles are applied
Your CSS changes color, shadow, or transform for instant feedback.
Render
=
✅
Responsive-feeling UI
Users see immediate confirmation that their action registered.
Compatibility
Browser Compatibility
The :active pseudo-class is supported in all major browsers, including Chrome, Firefox, Safari, Edge, and Opera.
✓ Universal · All browsers
Press states everywhere
:active has been part of CSS since the earliest days of the web and works consistently across platforms.
99%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
:active pseudo-class99% supported
Bottom line::active is safe to use in any modern project for click and tap feedback.
Wrap Up
Conclusion
The CSS :active selector is a simple but powerful tool for giving users visual feedback when they interact with clickable elements. A darker shade or slight shrink on press makes buttons and links feel responsive and intentional.
Remember that :active only lasts during the press. Combine it with :hover and :focus for a complete interaction story, and keep effects subtle for the best user experience.