Jump to content

Button vs input


Samuz

Recommended Posts

I don't exactly need help here. I'm just looking to start a discussion on the use of these two elements.

 

First off, these two work essentially the same (correct me if i'm wrong).

 

I can submit a form with

 

<input type="submit" />

or

<button type="submit"></button>

 

And they can be styled to essentially look the same. (With the use of :hover & :active)

 

I'm currently in the process of redesigning one of our old sites and i've noticed in th previous developers code he has used <input> in one place & <button> in others.

 

Normally i've always stuck to <input> and have never bothered to use <button>, because I just like the look of my code when creating forms all showing <input>. :v

 

So I just wanted to know if there was any REAL difference - apart from the default browser styles - from a semantic POV and if there are if somebody could point out when i'm really supposed to use <button> and when i'm supposed to use <input>.

 

Also pros/cons if any.

 

Thanks!

Link to comment
Share on other sites

I only use input's when it's submitting a form, and I use button tags when it's a button interacting with Javascript. I haven't really had much of that lately though, because there's much funner things to use in place of buttons with Javascript. :P

 

Also, button tags can turn about anything into a button. I'm not sure if input tags can. I always use /> closing so, I don't really know.

 

<button><img src="http://www.vietnamonline.com/userfile/article/linhphan/2011/10/Tet%20Vietnam.jpg" /></button>

 

Random Google pic .. don't ask. lol You can't do that with input tags though as far as I know. ( Just gave it a 2 second try to make sure. )

Link to comment
Share on other sites

In the past, one of the browsers (can you guess which one?), submitted all of the buttons no matter which one you clicked. So, if you have a form with multiple <BUTTON> elements to submit it (for different actions), it was impossible to tell which one the user choose. I don't know if the more recent versions of IE behave differently or not; and I have not tested in other browsers recently, either. Basically, I quit using multiple BUTTONS when I discovered this problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.