This is mainly a historical artifact.
This is due to the fact that it was much easier to apply an individual style to the anchor. You could easily create automatic button-watching anchors using more elements within the anchor itself.
Today, with advanced CSS settings and better browser compatibility, this is optional. If button is the correct semantic element, you have no reason to use a .
So, use bindings for links to other pages. It should always have href , and not just use # and onclick . Now you can use onclick anyway - just make sure href sends you the same data as onclick . This is very convenient if you want search robots to be able to navigate your site, even if actual users are represented, for example. a more responsive interface (for example, downloading updated content via AJAX). Make sure that the general methods for opening a link in a new window / tab still work (none of the Ctrl + click keys, right-click and middle-click should perform the onclick action).
Buttons are elements that can interact with the page you are currently on, regardless of whether this means running client scripts or submitting a form to the server.
EDIT
When editing your question, it is obvious that you should just use the anchor with a regular href . There is no reason to use either onclick or button , and you just make a simple hyperlink, which requires anchors.
source share