WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: "Go to Top" element, link or button

for

From: Glen Walker
Date: Jan 17, 2023 4:52PM


Links are for navigating, whether to a new page or a different location on the same page, so it sounds like you should have a link.

If the user can use the browser's “back“ button and navigate back to where they were before they selected the “go to top” element , then that's another argument that it should be a link.

But I can understand if someone argues for a button since this feels like an immediate action.

For me, it comes down to how it's implemented. If you make it a button and then you programmatically move the focus to the top of the section, then the user can't use the browser's back button and it would be OK to be a button instead of a link.

My first choice would be a link and use the browser's built-in functionality to move the focus for you. But I wouldn't fail WCAG if a button was used and implemented as mentioned above.