Why does the Cancel button in my HTML form submit it?
TechnologyI added `<button>Cancel</button>` beside the submit button in a practice form. Clicking Cancel sends me to the form's result page. I thought the word on the button told the browser what kind of action it was.
The intended Cancel action is just to close an optional preview, leaving the entered form values available. MDN says a button associated with a form defaults to submitting when its type isn't specified; `type="button"` has no default action. MDN's button reference
Should I give this button an explicit type and keep the preview-closing action separate? I'm trying to understand the cause before adding more code that intercepts every form submission.