button type=button is better than a href=#
There is the practice of using a href="#" for creating an interactive element. People disable the default behavior of a link using JS. As a result, you will get an element that behaves like a button.
Yes, it's the working solution at first sight. But the problem is this element has not become a button for browsers. If you click a right mouse button on this element you will see the following options in the context menu: "Open link in new tab", "Open link in new window", "Open link in incognito window".
When users see these options they wait they can open a link in a new tab or window. So they want to use these browsers features. But when they push on this link they will get the unexpected result.
Users will see just the start of a page. So the button element is a better solution because you get already an interactive accessible element. Also if users click on this element the context menu will not have options of a link. So you will not confuse your users.
❤ Thank you so much, my sponsors: Ben Rinehart, Sergio Kagiema, Jesse Willard, Tanya Ten, Spiridon Konofaos.
Folks, I'm a content creator with a passion for making more public content for the community. For that, I have to look for sponsors. They help me to stay afloat.
If you like what I do, please, grab my newsletter on Patreon. As words of appreciation, I’ll give you access to my content earlier others on a few weeks directly to your inbox. Thank you 🙏