[Solved] CSS disable hover effect

I need to disable the mouse hover on a particular button(not on all buttons) in the entire DOM. Please let me know how to achieve it using a CSS class.

i am using the below CSS class when my button is disabled. now i want to remove the hover effect using the same class.

 Cursor:text !important; Text-Decoration: None !important; 

The above class will take care of removing the hand sign and text underline on mouse over . Now i want to remove hover effect also. Please let me know.

Solution #1:

I have really simple solution for this.

just create a new class

    pointer-events: none;

and use this to disable any event on it. use it like:

<a href='' class='btn noHover'>You cant touch ME :P</a>
Respondent: Seetpal singh

Solution #2:

You can achieve this using :not selector:

HTML code:

<a class="button">Click me</a>
<a class="button disable">Click me</a>

CSS code (using scss):

.button {
  background-color: red;
  &:not(.disable):hover {
    /* apply hover effect here */

In this way you apply the hover effect style when a specified class (.disable) is not applied.

Respondent: Simone Colnaghi

Solution #3:

Here is way to to unset the hover effect.

.table-hover > tbody > tr.hidden-table:hover > td {
    background-color: unset !important;
    color: unset !important;
Respondent: Pawan Kumar

Solution #4:

Add the following to add hover effect on disabled button:

    /*your code goes here*/     
Respondent: Rasel

Solution #5:

To disable the hover effect, I’ve got two suggestions:

  • if your hover effect is triggered by JavaScript, just use $.unbind('hover');
  • if your hover style is triggered by class, then just use $.removeClass('hoverCssClass');

Using CSS !important to override CSS will make your CSS very unclean thus that method is not recommended. You can always duplicate a CSS style with different class name to keep the same styling.

Respondent: infiniteloop

Solution #6:

From your question all I can understand is that you already have some hover effect on your button which you want remove.
For that either remove that css which causes the hover effect or override it.

For overriding, do this

    //overriding css goes here

For example if your button’s background color changes on hover from red to blue. In the overriding css you will make it as red so that it doesnt change.

Also go through all the rules of writing and overriding css. Get familiar with what css will have what priority.

Best of luck.

Respondent: shinobi

Solution #7:

Do this Html and the CSS is in the head tag. Just make a new class and in the css use this code snippet:


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      .buttonDisabled {
        pointer-events: none;
    <button class="buttonDisabled">Not-a-button</button>
Respondent: John Snyder

Solution #8:

I tried the following and it works for me better


  color: inherit;
  text-decoration: inherit;
  &:hover {
    color: inherit;
    text-decoration: inherit;
Respondent: user8702464

Solution #9:

     background-color: unset !important;
    color: unset !important;

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy