Most websites nowadays add a scroll to top button on their websites. Sometimes landing page websites could be long in height, and when a visitor scroll down the webpage and for some reason, if they want to go back to the top for some information, they have to scroll back to the top. This experience sometimes annoys the visitor, and if they have to do this for every page, they will leave the website. If we think from the user perspective, every landing page website should have a back-to-top button website. Download the code
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (14)
In my opinion, the best way to do this is by adding an ID to the NAV bar and just linking to the ID from a button at the bottom.
It's simpler. You can use
<a href="#">Scroll To Top</a>
to do it.How can you create a Scroll To Top button with just HTML?.
Kavindu Santhusa ใป Dec 24 ใป 2 min read
Yeah that would be way easier and with bootstrap itll add animations too...
Yes. Itโs also better for the user experience because that is what you are doingโฆ Moving to another section on the page. With JavaScript and doing it this way it could be very confusing to screen readers.
Also bootstrap is way easier than that method and almost does it better than that method so we wont have to unnecessarily debug the code if smth goes wrong just go to the docs view the syntax type it out with the classes...
Absolutely no need to use bootstrap for this. It makes sense if you already use bootstrap for the whole site, but makes no sense to include 1 huge library for such a simple thing.
No but who doesnt use bootstrap
Yellow, I agree. You can just add smooth scrolling to the HTML in CSS.
I don't, and many others don't as well. Don't make assumptions:).
K i admit im a bit new to this stuff and most programmers that i have seen use bootstrap for their projects.
No worries! Weโre all new at something.
Starry, I don't use Bootstrap. (: I stick to Tailwind, or custom CSS
Using scroll behaviour is just the way to go. I see no reason why I should use jQuery to implement this.
Why jQuery when you have native support for this? developer.mozilla.org/en-US/docs/W... and developer.mozilla.org/en-US/docs/W...