views:

32

answers:

1

Is there any option, or special selector to change the style for a pressed button, what I mean by that..when a user clicks a button I want to change the style for that button? Is there any option to do that like: :focus or only with javascript click/focus event?

+4  A: 

I think you are looking for the :active pseudo-class...

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      #btn { border: solid 5px red; padding: 5px; }
      #btn:hover { border-color: green; }
      #btn:active { border-color: blue; }
    </style>
  </head>
  <body>
    <input id="btn" type="submit" />
  </body>
</html>

Note: if you are using both :hover and :active on a single element, the :hover definition must come first.

Josh Stodola
Yup! thx a lot man
Uffo