Animated Back to Top Button

Beginner

Smooth animated button that appears when scrolling down and smoothly scrolls back to the top of the page.

Live Preview

Code Implementation

HTML
<div class="back-to-top-demo">
  <div class="demo-content">
    <h3>Scroll Down to See the Button</h3>
    <p>This is a demonstration of the back to top button. Scroll down to see it appear.</p>
    <div class="spacer"></div>
    <p>Keep scrolling...</p>
    <div class="spacer"></div>
    <p>Almost there...</p>
    <div class="spacer"></div>
    <p>Now scroll back up to see the button in action!</p>
  </div>
</div>

<button class="back-to-top" id="backToTopBtn">
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
    <path d="M12 19V5M5 12l7-7 7 7"/>
  </svg>
</button>

Snippet Features

Responsive Design: Yes
Dark Mode Support: Yes
Category: navigation-menus
Difficulty Level: Beginner

Browser Compatibility

🟢
chrome 50+
🟠
firefox 45+
🔵
safari 10+
🟦
edge 15+