HTML Back to Top Button Code

Add a back-to-top control to your HTML website to streamline navigation, support smoother browsing, and make long content easier for visitors to explore.
4.8 rating
10,000+ reviews
Free plan available
Create Widget for Free
No credit card needed
HTML Back to Top Button Code

Create your Back to Top widget

Configure your Back to Top button and add it to your HTML website for free!

Screenshots

HTML Back to Top Button Code
1 / 6

Why People Love Elfsight

Wouldn’t it be nice if your website just guided people effortlessly? The Elfsight Back to Top widget does exactly that. It gives readers a friendly shortcut to jump to the start of a page, making long pages feel lighter and easier to explore. Setup takes minutes and works even if you’re not a tech wizard – just copy a small snippet of HTML code, paste it into your website, and you’re ready to roll.

If you’ve ever wondered how to make a Back to Top button in HTML, this widget saves you the trouble of coding from scratch. It takes care of the design, animation, and placement automatically.

Did you know?

Nielsen Norman Group found that users spend most of their viewing time near the top of a page.

Start using the Elfsight Back to Top widget today to give visitors a speedy way up – you’ll make long pages feel tidy and stress-free.

Key Features of the HTML Back to Top Button

Let’s keep navigation simple, fast, and friendly. Here’s what you can expect day-to-day:

  • Flexible placement: Choose a neat floating button or place it inline inside your content – both are easy to set up.
  • Custom look and feel: Colors, shapes, icons, size, shadow, label – match your branding in a few clicks.
  • Smart behavior: Show after X pixels scrolled, hide on top, add smooth scroll, and adjust scroll speed to your preference.
  • Mobile-ready by default: Looks great on phones and tablets, with tap-friendly hit areas and lightweight performance.
  • Multiple positions: Bottom-right, bottom-left – pick what fits your layout best.
  • Accessibility-friendly: Aria labels, focus states, and keyboard navigation help everyone use it comfortably.
  • No-code install: Copy the small code, paste it where you want it – that’s the whole story.
  • Low weight: Loads fast and stays out of the way, even on content-heavy pages.

Open the editor and test all features – no signup needed

How to Add the Back to Top to HTML

There’re two simple paths depending on where you want the button to appear.

Method 1: Inline Back to Top

Use this if you want the button inside your page content (like after a long article).

  1. Choose a template: Open the Elfsight editor and pick a layout you like.
  2. Style it: Set icon, color, and size, then preview how it looks.
  3. Copy the installation code: Click “Add to website for free” to get your snippet.
  4. Paste into your HTML: Add the snippet where you want the button to appear within your page markup.

Method 2: Floating Back to Top

Great for a sticky button that follows the reader as they scroll.

  1. Pick the floating layout: In the editor, select a floating style.
  2. Adjust position and behavior: Set bottom/right offsets, show-after-scroll value, and smooth scroll.
  3. Copy the installation code: You’ll get a small script block.
  4. Paste before the closing </body> tag: The button will appear on every page where you add the snippet.

Need help? Visit our Help Center for detailed step-by-step guides. You can share ideas in the Wishlist and track updates in the Changelog.

Can I add a Back to Top button to a static HTML website?

Yes, Elfsight works on any static HTML website. Simply paste the installation code into your page source where you want your widget to appear.

Do I need special hosting to use the Back to Top widget on HTML?

No special hosting plan is required. As long as your HTML website supports JavaScript, the widget will display and function properly.

When does the Back to Top button appear on an HTML page?

The button becomes visible once visitors scroll beyond the percentage you define in the display settings, ensuring it appears only after meaningful page movement.

Can I control how fast the page scrolls back to the top?

Yes, Elfsight allows you to define the scroll animation duration in seconds, so your HTML page returns to the top smoothly at a speed that matches your design feel.

What’s the difference between floating and embedded modes?

In floating mode, the button stays visible while users scroll through your HTML layout, whereas embedded mode places it in a fixed section like a footer or content block.

Can I show the Back to Top widget only on certain HTML pages?

Yes, display rules let you include the widget across your entire HTML website or exclude specific URLs where the button isn’t necessary.

How does the Scroll to Top widget behave on mobile devices?

On mobile screens, the button adapts its size and positioning, supports touch interaction, and appears according to optimized scroll settings.

Can I adjust the button’s position to avoid overlaps?

Yes, you can apply custom pixel offsets so the widget doesn’t conflict with chat bubbles, banners, or other floating elements.

Pricing

14-day money back guarantee. Risk-free, you can cancel at anytime.
Elfsight Apps
Cross-platform solution
from $0 / month
start with free plan
Unlimited websites
Fast customer support
Free installation help
Special offer for multiple apps
Fully customizable