Mickaël Mickaël - 1 year ago 63
HTML Question

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

tags have exactly the same appearance, and I found this :

Cross-browser rendering

As a best practice, we highly recommend using the
whenever possible to ensure matching cross-browser rendering.

What is the reason that can lead me to use a
tag (which doesn't have a href attribute) instead of a
for navigation ?

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]

Answer Source

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...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download