Interactive online courses HTML Academy
2026-03-09 14:05 Diff

Great: we have learned how to scroll down the page using JavaScript! We need the page to scroll back up to the beginning when the user clicks on the “Up” button.

We already found the button. Now we need to add the onclickevent handler to it. After that, transfer the instruction with scrollTo inside the handler and verify that when you click on the button, the page scrolls back up to the beginning.

By default, automatic scrolling occurs very quickly in browsers: it seems to instantaneously jump back to the top of the page. It in order to make the transition less abrupt, we used the scroll-behavior CSS property with the smooth value. You can find out more about this property from the specification. Note that this type of scrolling can make some people sick, and Operating Systems allow them to indicate that they prefer reduced motion. CSS can use the Reduced Motion Media Query to override smooth scrolling for people with vestibular disorders.