Samuz Posted September 17, 2012 Share Posted September 17, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/268465-button-vs-input/ Share on other sites More sharing options...
codefossa Posted September 23, 2012 Share Posted September 23, 2012 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. 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. ) Quote Link to comment https://forums.phpfreaks.com/topic/268465-button-vs-input/#findComment-1380214 Share on other sites More sharing options...
DavidAM Posted September 23, 2012 Share Posted September 23, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268465-button-vs-input/#findComment-1380216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.