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
2009-09-02 12:33:48
i would use it but am not very sure as to what changes to apply so that the button doesn't get indented.
2009-09-02 12:48:40
buttons use little `padding`
knittl
2009-09-02 13:14:33
yeah. N even after giving the paddina as 0 the indentation still remains
2009-09-23 10:11:47
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
2009-09-02 13:38:54
A:
adardesign
2009-09-02 15:07:02