11 Responses to “The Button Element”

- Andy Knight
- June 13th, 2008
Well, you got me. We were just talking the other day about how I preferred the default browser buttons, but honestly, I only prefer them in Safari and Camino. IE and FF buttons are functional but not overly attractive.
My favorite reason that you mentioned for using the button tag is being able to target your CSS code to affect only the text input without affecting the style of the button too. How many times have I set a width to the input text boxes and end up with a 300 pixel wide button too. Yuck.

- chuck
- June 13th, 2008
@Andy Knight: Agreed, if all browsers were consistent in how they rendered buttons and they all looked as nice as the Safari or Camino buttons, I’d be much more inclined to leave them alone.

- Jeff Adams
- June 13th, 2008
Button elements are great except for one major problem. If you have a form that contains multiple buttons and use the value=”whatever” attribute to detect which button is actually pushed you’ll be out of luck. IE doesn’t pass the values of button elements at all. If you only have one button element and don’t care about the value then no problem.

- chuck
- June 13th, 2008
@Jeff Adams: that is great information to know. Thank you, Internet Explorer, yet again.

- Matthew Pennell
- June 16th, 2008
You could actually move the cursor declaration into the initial button.send declaration - that way IE6 and below get the benefit of it as well (as they don’t support the :hover).
You should also specify two different cursor values: “pointer” and “hand” (IE5.x doesn’t understand one of them, I forget which one without looking it up).
I’ve been using the button element for years now - for your basic contact form, passing the value through rarely matters.

- Alan
- June 16th, 2008
Sadly, if you are in a .NET environment like I am you are forced to use “input” buttons, as it is forced upon you to use the .NET postback functionality.
I do use the button element where possible, mostly AJAX applications that rely on the onclick event of the button to perform some actions.
What a joy it would be to not be locked down to MS.

- Geof Harries
- June 17th, 2008
Are you required to use a button inside of a form element? I ask because I’m building templates with buttons (the Learn More genre) but they’re not part of a form, just a link to another page in the site.

- David
- June 27th, 2008
All good stuff Chuck. I had a ureaka moment with the button tag about 1/2 a year ago and I’ve never looked back.
Keep promoting the good stuff

- Jeff Adams
- June 27th, 2008
Oh one more thing, cursor:hand doesn’t work in firefox or safari. cursor:pointer is the same graphic and works in IE6+ and all the other browsers. If you need to accomodate IE5.x include both the cursor styles.

- chuck
- June 27th, 2008
Thanks for all the comments/suggestions, everyone!
@Jeff Adams: I updated my code (and the code above) to reflect that. Much thanks!

The cleaner :hover possibilities are reason enough. I’d totally forgotten about this element. Thanks for reminding me.