How to Embed a Stock Ticker Using HTML
A scrolling stock ticker for any website in two lines of HTML: no API key, no build step, and no framework required.
A scrolling stock ticker is one of those features that looks simple until you try to build it. You need a quote source, an API key you don't want to expose in client code, a CSS animation that doesn't jank, a pause on hover, dark mode, and a plan for what happens when the data request fails.
If you just want the strip on your page, you can skip all of that. This tutorial shows how to embed a free ticker tape with plain HTML, how to configure it, where to place it in common layouts, and how to make it work in React and Next.js.
The embed
Paste this where you want the ticker to appear:
<div class="ql-tickertape" data-symbols="AAPL,MSFT,NVDA,AMZN,SPY,QQQ" data-theme="light">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
<script src="https://www.quotelinks.com/widgets/tickertape.js" async></script>
That's the whole integration. The <div> is a placeholder that holds your settings, and the script finds every .ql-tickertape element on the page and turns it into a scrolling strip with each symbol's latest price and daily change. Clicking a symbol opens its quote page in a new tab, so your visitor's page stays open.
If JavaScript is disabled or blocked, the div's text and link are shown instead, so the page never ends up with an empty gap or a broken box.
You can also build the code visually on the ticker tape widget page, which has a live preview and a copy button.
Configuration with data attributes
Everything is set with data-* attributes on the div. No JavaScript config objects.
| Attribute | Values | Effect |
|---|---|---|
data-symbols |
AAPL,MSFT,SPY |
Up to 20 US stocks and ETFs, shown in this order. Omit it to get the largest US companies plus SPY and QQQ. |
data-size |
regular (default), compact |
Regular is 40 px tall with symbol, price and change. Compact is 32 px with symbol and change. |
data-theme |
light (default), dark, auto |
auto follows the visitor's system light/dark setting. |
data-style |
boxed |
Rounded border, for a strip inside an article or sidebar. Leave it out for full width. |
data-speed |
slow, normal (default), fast, still |
still turns off scrolling; visitors swipe the strip instead. |
Three layouts that work well
1. A full-width strip across the top of every page
Put the embed right after the opening <body> tag, before your header:
<body>
<div class="ql-tickertape" data-symbols="SPY,QQQ,DIA,IWM,AAPL,MSFT,NVDA,GOOGL,AMZN,META,TSLA"
data-size="compact" data-theme="auto">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
<header>…</header>
compact plus auto is the least intrusive combination for a site-wide strip: 32 px high, and it matches dark-mode visitors without extra CSS.
2. A boxed strip inside an article
When an article discusses a handful of companies, a ticker with just those symbols under the intro gives readers live context:
<div class="ql-tickertape" data-symbols="JPM,BAC,WFC,C,GS,MS" data-style="boxed" data-speed="slow">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
slow matters here. A ticker inside body text competes with the words around it, and a slower scroll is easier to read and less distracting.
3. A static row on a dark dashboard
For a dashboard or a page where motion would be annoying, turn scrolling off:
<div class="ql-tickertape" data-symbols="SPY,QQQ,TLT,GLD,USO" data-theme="dark" data-speed="still">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
Using it in React or Next.js
The script scans the page for .ql-tickertape elements and also watches for new ones added later, which is what single-page apps and page builders need. In React you render the div like any other element and load the script once.
React (Vite, CRA):
import { useEffect } from "react";
export function TickerTape({ symbols = "AAPL,MSFT,NVDA,SPY" }) {
useEffect(() => {
if (!document.querySelector('script[src*="widgets/tickertape.js"]')) {
const s = document.createElement("script");
s.src = "https://www.quotelinks.com/widgets/tickertape.js";
s.async = true;
document.body.appendChild(s);
} else {
window.qlTickertape?.scan();
}
}, [symbols]);
return (
<div className="ql-tickertape" data-symbols={symbols} data-theme="auto">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
);
}
Next.js (App Router):
import Script from "next/script";
export default function Layout({ children }) {
return (
<html lang="en">
<body>
<div className="ql-tickertape" data-symbols="SPY,QQQ,AAPL,MSFT,NVDA" data-size="compact">
Stock quotes by <a href="https://www.quotelinks.com/">Quotelinks</a>
</div>
{children}
<Script src="https://www.quotelinks.com/widgets/tickertape.js" strategy="afterInteractive" />
</body>
</html>
);
}
If you change the symbols after the widget has loaded, window.qlTickertape.scan() re-reads the page.
What to check in any ticker widget
Whichever widget you use, these are the details that decide whether it helps or hurts your page:
- Style isolation. A widget that injects global CSS can break your layout, and your CSS can break it. This one renders inside a Shadow DOM, so neither side leaks into the other.
- Off-screen cost. An animation that keeps running when nobody can see it wastes CPU and battery. This ticker pauses when it scrolls out of view.
- Pause control. Moving text needs a way to stop it. The strip pauses on hover and when it receives keyboard focus.
- Reduced motion. Visitors who set
prefers-reduced-motionin their OS get a still strip they can swipe, with no scrolling. - Network behavior. The script is about 4 KB gzipped, loads async, sets no cookies, and fetches prices once per page view instead of polling.
- Honest timestamps. A ticker should say how fresh its prices are. During market hours the strip shows a delayed "as of" time; after the close it shows the closing date.
Platform notes
- WordPress: a Custom HTML block for one page, or your theme's header area / a header-and-footer plugin for every page.
- Blogger: Layout → Add a Gadget in the header section → HTML/JavaScript.
- Squarespace: a Code block with "Display Source" off.
- Ghost: an HTML card in a post, or after
<body>indefault.hbsfor every page. - Wix: Embed HTML, stretched to full width, 42 px high (34 px for compact).
- Hosts that strip
<script>from posts can't run the widget, but the fallback link still shows.
Other embeds in the same style
The same two-line pattern works for a stock quote card with a one-month chart and for daily market movers; the full set is on the free stock widgets page.
Terms
The widgets are free for personal and non-commercial sites, as long as the credit link stays visible. Commercial sites need a written agreement. Prices are for information only and are not investment advice.
If you add the ticker to a project, drop the link in the comments. I'd like to see where it ends up.
Comments
Join the discussionNo comments yet. Be the first to comment.