What’s the difference between type=” submit ” and type=” button ”? in Html

Anna Ikoki
Apr 15, 2022
photo by Roberto. / Unsplash

You have probably seen these three interchangeable codes below. Probably asking yourself, when should I use which? Then say, ‘Ugh watevs.., I will just add another cup of coffee or tea.’

<button type="button">Submit</button>

or

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

or even

<label for="submit">Submit</label>
<input type="submit" id="submit">

It’s to do with the ‘default’ activity of type="submit" . Tags with the type submit will submit a form to the server by default. While the Html tags without that type will submit the form with an extra code.

--

--