This may end up being closed as too opinion-based (there are multiple ways you can do it), but at the very least I can try to offer some reasoning behind my opinions.
a
tags have certain functional behavior behind them as-is. They will often modify the URL even if they don't navigate you anywhere, and in JavaScript you will have to fight their default behavior. All that you're using them for much of the time is their styling.
IF you are using their href tag for default navigation behavior, then I would recommend writing <a class="myprefixButton">
, and setting up a CSS style on .button
that gives them padding and a rounded border to make them look like buttons.
If you are submitting a form, use <button type="submit">
, or if you're only linking to JavaScript, use <button type="button">
. That last one has absolutely no inherited behavior from anywhere else, making it perfect to build from the ground up in JS without needing to cancel anything.
Finally, if you are submitting a form with JavaScript, use <button type="submit">
and listen on the form element for a 'submit' event. Reason being, you also want to submit if the user presses enter, or submitted through some other form like an accessibility toolkit.