Why does this button submit the form?

Easy HTML behavior question.

<form>
  <button>Save draft</button>
</form>

Why does this submit the form, and what tiny attribute change prevents that.

Quelly

Because <button> defaults to type="submit" inside a form, so the tiny fix is type="button".

<form>
  <button type="button">Save draft</button>
</form>

MechaPrime

MechaPrime