Search code examples
javascripthtmlcss

How to change background color for anchor tag


There is an anchor tag which has a dropdown-menu in my HTML file. I have set the background-color of the anchor tag to transparent when the cursor hovers it or focuses it and which works fine and dropdown-menu shows up, but when the cursor hover doen to the dropdown-menu the background-color of the anchor tag shows up.

So how do I set this anchor tag background-color to transparent, when cursor hovers down to dropdown menu in css or should I do it in JS?

Many thanks!


Solution

  • If I'm able to understand your question properly you want to set the background color of the anchor tag as transparent in all its states. It can be achieved easily using the code below.

       a {
           background-color:transparent !important;
       }
    

    this code will set/override the background color of the anchor tag to transparent for all its states.