Is using button's onClick callback to navigate is a semantically correct?
Like in the title.
Is calling
5 Replies
So i always thought its not
but someone just told me that I am not right. What do you think?
if you expect the user to click something and then be redirected somewhere else, use a <a>
That's what we have links for...
Buttons are for interactions
The "Simple set of rules" here puts it pretty nicely - https://a11y-101.com/design/button-vs-link
anchor tag (<a>) do more than just change the url on click. you can right click them to copy the link, middle click to open in a new tab, press space or enter after focussing it to follow the link. Search engines use them to explore your site too.
unless you want to reimplement every single one of those features... don't use buttons in place of links
ahh thats why I hate frontend somtimes
a guy who is decision making
is forcing me to use button
because "he says so"
thanks
for the help