views:

279

answers:

3

I need to make a button look like a link using CSS. The changes are done but when i click on it, it shows as if its pushed as in a button. Any idea how to remove that so that the button works as a link even when clicked?

+2  A: 

try using the css pseudoclass :focus

input[type="button"], input[type="button"]:focus {
  /* your style goes here */
}

edit as for links and onclick events use (you shouldn’t use inline javascript eventhandlers, but for the sake of simplicity i will use them here):

<a href="some/page.php" title="perform some js action" onclick="callFunction(this.href);return false;">watch and learn</a>

with this.href you can even access the target of the link in your function. return false will just prevent browsers from following the link when clicked.

if javascript is disabled the link will work as a normal link and just load some/page.php—if you want your link to be dead when js is disabled use href="#"

knittl
i would use it but am not very sure as to what changes to apply so that the button doesn't get indented.
buttons use little `padding`
knittl
yeah. N even after giving the paddina as 0 the indentation still remains
A: 

You can't style buttons as links reliably throughout browsers. I've tried it, but there's always some weird padding, margin or font issues in some browser. Either live with letting the button look like a button, or use onClick and preventDefault on a link.

Jacob R
A: 
adardesign