When should I use a button (<button>) or a link (<a>) in HTML?
I was reading the Bootstrap documentation about the button tags (http://getbootstrap.com/css/#buttons-tags), as <button>
and <a>
tags have exactly the same appearance, and I found this :
Cross-browser rendering
As a best practice, we highly recommend using the
<button>
element whenever possible to ensure matching cross-browser rendering.
What is the reason that can lead me to use a <button>
tag (which doesn't have a href attribute) instead of a <a>
for navigation ?
Maybe <button>
is better when designing web applications when it interacts with the page itself, and of course for submitting forms, but is it all ?
[this question is related to SEO: <button> vs <a> HTML tags but the question is not the same]
Thanks to the comments on my question, this is the answer I believe to be true :
I have to use <a>
for links and navigation between page / views.
I have to use <button>
for actions, for example on the current page : validating/resetting a form, showing a modal...