I am creating CSS buttons for both links and form submissions. I use almost the same markup for both, with a different wrapper.
HTML Examples:
@Eric, save yourself time and go with a solution that's already been fought with and tested and verified in all the major browsers.....jQuery UI buttons does this right out of the box. As an extra bonus, they can be styled with Themeroller for quick changeout on the backend and even user-selectable themes on the front-end.
Check out this tut for more details.
There's a big stack of issues to consider here.
I'm going to be very verbose with the changes required to fix this.
To cajole it into working in IE6/7, these were my steps:
display: inline-block
instead of float
for the internals of the button
.vertical-align: top
.overflow: visible
(as per here: IE7 CSS padding issue - cannot figure out), and display: inline
.There's also some IE6 specific issues of low priority:
button:hover
selector will not work in IE6. IE6 only supports :hover
on a
elements. To work around this, you can use the Whatever:hover fix..png
image, in IE6 there is a grey background instead of transparency; there are fixes available. Though in this case, it's hard to notice. I'd say leave this one be - the extra effort is not worth the improvement.More important is the fact that your current implementation is slightly broken in Firefox:
http://keeleux.com/dev/button/
(screenshot from Firefox 4)
line-height
to the internal em
s.Note that a fair few of those issues can be worked around by simply using an a
instead of a button
.