How to Add a Pressed Effect on Button Click in CSS? Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report To add a pressed effect on a button click using only CSS, you can use the :active pseudo-class, which applies styles when the button is clicked or tapped.1. Using CSS transform PropertyThe CSS transform property enables you to adjust an element's appearance by applying scaling, rotation, translation, or skewing effects. By leveraging the transform property, you can create a "pressed" effect on a button, making it look as though it's being pushed down when clicked.Syntaxtransform: scale() html <!DOCTYPE html> <html> <head> <style> .btn { border: none; padding: 12px 40px; font-size: 16px; background-color: green; color: #fff; border-radius: 5px; box-shadow: 7px 6px 28px 1px rgba(0, 0, 0, 0.24); cursor: pointer; outline: none; transition: 0.2s all; } /* Adding transformation when the button is active */ .btn:active { transform: scale(0.98); /* Scaling button to 0.98 to its original size */ box-shadow: 3px 2px 22px 1px rgba(0, 0, 0, 0.24); /* Lowering the shadow */ } </style> </head> <body> <button class="btn">Button</button> </body> </html> Output2. Using translate() FnctionThe translateY() function moves an element along the Y-axis by a specified amount. This movement can simulate the button being pressed downwards.Syntaxtransform: translateY() html <!DOCTYPE html> <html> <head> <style> .btn { padding: 15px 40px; font-size: 16px; text-align: center; cursor: pointer; outline: none; color: #fff; background-color: green; border: none; border-radius: 5px; } /* Adding styles on 'active' state */ .btn:active { box-shadow: 7px 6px 28px 1px rgba(0, 0, 0, 0.24); transform: translateY(4px); /* Moving button 4px to y-axis */ } </style> </head> <body> <button class="btn">Click Me</button> </body> </html> OutputCSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples. How to add a pressed effect on button click in CSS ? Comment More infoAdvertise with us Next Article How to Add Shadow to Button in CSS ? F frikishaan Follow Improve Article Tags : CSS CSS-Misc CSS-Questions Similar Reads How to Add Shadow to Button in CSS ? This article will show you how to add shadow to a button using CSS. Button shadow can enhance its visual appeal and make it stand out on your webpage. This article will cover various approaches to adding shadow to a button using CSS. Table of Content Add Shadow on button using box-shadow PropertyAdd 3 min read How to create Incoming Call Animation Effect using CSS ? In this article, we will learn how to create an incoming call animation effect, by using CSS. Approach: To create this effect, we essentially need to animate the shadow effects around the element frame, which can be easily manipulated using the CSS box-shadow property. It is described by X and Y off 2 min read How To Make A Button Linear Gradient Color Border In Tailwind CSS? Creating visually appealing buttons can significantly enhance the user interface of your web application. One popular design trend is the use of linear gradient borders. In this article, we'll explore how to make a button with a linear gradient color border using Tailwind CSS.A button with a linear 2 min read How to add a style on a condition in Tailwind CSS ? In this article, we will see how to integrate conditional styling into our web projects using Tailwind CSS. There are various Tailwind CSS classes are available, although, it usually involves dynamically adding or removing classes using JavaScript. There are different approaches to implementing the 3 min read How to add a button to an image using CSS ? In the article, we will explore how to add a button to an image using CSS. Adding a button to an image is often used to create an overlay effect to a button on an image that provides an interactive and engaging layout on a webpage. We can achieve this effect with the combination of various CSS Prope 4 min read How to create Animated Hovered 3-D Buttons Effect using CSS ? The hovered 3-D effect on a button is an effect in which the button appears to come toward the user on hovering. These buttons are created using HTML and CSS.Approach: The best way to animate the HTML objects is done by using CSS @keyframes and by setting the transitions at different stages.Example: 3 min read Like