Programming Tips - html: Avoid an html button from causing a submit of the form

Date: 2015jan29 Update: 2025jul16 Language: html Q. html: Avoid an html <button> from causing a submit of the form I have:
<button onclick="doSomething()">Do Something</button>
How can I avoid it submitting the form its in? A. You need to add type="button" (yes, that seems redundant) like this:
<button type="button" onclick="doSomething()">Do Something</button>