Search code examples
cssbuttonstyling

CSS change button style after click


I was wondering if there was a way to change a button's style, in css, after it's been clicked, so not a element:active.


Solution

  • If you're looking for a pure css option, try using the :focus pseudo class.

    #style  {
        background-color: red;
    }
    
    #style:focus {     
        background-color:yellow;    
    }