<button> vs. <input type=“button” />

My question what I should use in between <button> vs. <input type=“button” />. I’m search on google for it but don’t get a solid answer.

With <button> you can wrap other elements and use the button as a container, whereas type="button" restricts you to simple text label buttons. You can put <img>s inside <button> elements for instance.

Not 100% certain what is supported and what the standards say, though.

I’m not sure of the behavioural differences between those, but I presume that both act either as submit buttons (inside forms) or they need JavaScript to add interactivity.

The following tutorial will be helpful to you for understanding the difference vs.


@Claire_Anderson: we do appreciate you contributing to the discussion, but the links you provided are both very old: from 2007 and 2005, to be precise. As things tend to move on quite quickly in web dev, we would much prefer that any links you post be considerably more recent than that.

both can act as a button inside a form (button defaults to type=“submit” in that case or you can specify type=“button” to have it behave like the input.

<button> is also allowed outside a form where it defaults to type=“button” (as there is no form to submit)


Thaks your replay @felgall. This form related information is really useful :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.