What are the differences between those two?

Hey, y’all!

I have a confusion about those two elements:

<button type="submit">Submit</button>
<input type="submit" placeholder="Submit">

Is there any specific difference between those two or not?


The first one is a button with the text “Submit”. The second one is an input field, that has a place holder text of “Submit” - the placeholder is meant to be a suggestion/reminder and disappears once you start typing.

[EDIT: Ignore my answers, I don’t normally work with HTML. Read Lasjorg’s answer.]

You might use them together - an input field where you type something and then press the submit button. But “Submit” probably isn’t the placeholder you want, unless you want them to enter the text “Submit”.

another difference is that a button doesn’t always have to look like a button.
You can use the button tag to make an image into a button but you can’t do that with input.

1 Like

Just to be clear. They are asking about an input of type submit vs a button element. They are both buttons.

Functionally they are the same as form submission buttons. But I would suggest using a button element. It is easier to style and can take content, it also is more explicit. A button inside a form is by default a submit button unless you explicitly set the type attribute to button.

1 Like

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