HTML Marquee Generator: Scrolling Text With CSS
What Is a Marquee?
A marquee is a strip of text that scrolls across the page by itself, like the news ticker at the bottom of a TV
channel or the “Free shipping this week” bar at the top of a shop. The name comes from the old HTML
<marquee> tag, which did exactly that. Today the same effect is usually made with a CSS animation.
This generator writes the code for you. Type your items (text, emoji, links or small pictures), pick the direction,
speed and colors, and watch the real result in the preview. Then copy modern CSS code, or the old tag if that's what
you need. It all runs in your browser, and your last marquee is remembered for next time.
How to Use It, Step by Step
Five quick steps. The preview runs the exact code you copy.
Step 1 Pick a Preset
Click a tile under Presets: News ticker, Announcement bar, Row of names, Stock ticker style,
Vertical notices, Bouncing text, Sale banner or Emoji row. If you haven't typed your own items yet, the preset
brings sample text along. Once you have, it only changes the look.
Step 2 Type Your Items
Put one item on each line in the Items box. Three kinds of lines work:
- Text or emoji:
Gift cards are back in stock 🎁 - A link: the text, a bar, then the address:
Big sale | https://example.com/sale - A picture:
image: https://example.com/logo.png | Shop logo (the part after the bar is the alt text)
Pick a separator to go between items, like a dot or a star. Quotes, < and & are escaped in the code, so they can't break your page.
Step 3 Set the Movement
Choose a Direction (left, right, up or down) and a Style: Loop goes round and
round, Bounce slides to the other side and back. Set the speed in seconds per loop, or type a speed in pixels per
second and the tool works out the seconds. For up and down, set the window height.
Step 4 Style It and Make It Pausable
Change the font, colors, padding, border and corners. Keep Pause on hover and the
Pause button on: they let people stop the text to read it, and the button works with the keyboard
too. Fade the edges makes the text melt in and out at the sides.
Step 5 Copy the Code
Read the Checks under the code, then press Copy all (or Copy HTML and Copy CSS
separately), or Download a small page to try on its own. Put the <style> block
in your page's <head> and the HTML where the bar should go.
💡 Want the old tag? Pick Old <marquee> tag at the top of the controls. It's one element
with inline styles, so it's easy to paste into places that don't allow a <style> block.
Modern CSS or the Old <marquee> Tag?
Both make text scroll. The tag is shorter to write, but CSS does the job better in almost every way:
| <marquee> tag | Modern CSS |
| Part of today’s HTML | No, it’s obsolete | Yes |
| How it moves | In small jumps | Smoothly |
| Loop without a gap | No, it waits until the text has left | Yes, with a second copy |
| Pause on hover | Needs onmouseover | One CSS rule |
| Pause with the keyboard | No | Yes, with a Pause button |
| Stops for “reduce motion” | No | Yes |
The <marquee> Tag
The tag needs nothing else: wrap your text in <marquee> and it scrolls from right to left, forever.
It started as a browser extra in the 1990s. Today it's obsolete in the HTML standard: it's still described there so
browsers keep running it and old pages don't break, but new pages shouldn't use it, and validators like the
HTML Validator flag it.
The code:
<marquee>Hello! I'm the old marquee tag.</marquee>
Its attributes control the movement:
| Attribute | What it does | Default |
behavior | scroll goes round and round, slide comes in once and stops, alternate bounces between the edges. | scroll |
direction | Which way it moves: left, right, up or down. | left |
scrollamount | How many pixels it moves each step. Bigger is faster. | 6 |
scrolldelay | Milliseconds between steps. Smaller is faster, but browsers raise anything under 60 to 60. | 85 |
truespeed | Lets scrolldelay go under 60. Very fast and jumpy. | off |
loop | How many times it runs. -1 means forever. | -1 |
width, height | The size of the box. Up and down need a height. | auto |
bgcolor | Background color. Use CSS background-color instead. | none |
hspace, vspace | Space outside the box. Use CSS margin instead. | 0 |
Bounce with behavior="alternate":
<marquee behavior="alternate" scrollamount="3"
style="background: #fef9c3; padding: 8px;">
I bounce from side to side
</marquee>
How the CSS Marquee Works
The CSS version uses a box with overflow: hidden and moves the items inside it with
transform: translateX() in a @keyframes animation. The trick for a loop without a gap is to
put the items in twice. Both copies move left by exactly one copy's width plus the gap, then start again. At that
moment the second copy is exactly where the first one began, so the restart can't be seen.
The code (a short version of what the generator writes):
<style>
.marquee {
--gap: 24px;
display: flex;
gap: var(--gap);
overflow: hidden;
padding: 8px 0;
color: #ffffff;
background-color: #0b0f19;
}
.marquee-group {
display: flex;
flex-shrink: 0;
justify-content: space-around;
gap: var(--gap);
min-width: 100%;
margin: 0;
padding: 0;
list-style: none;
animation: scroll 12s linear infinite;
}
.marquee:hover .marquee-group {
animation-play-state: paused;
}
@keyframes scroll {
to {
transform: translateX(calc(-100% - var(--gap)));
}
}
@media (prefers-reduced-motion: reduce) {
.marquee-group {
animation: none;
}
}
</style>
<div class="marquee">
<ul class="marquee-group">
<li>First news item</li>
<li>Second news item</li>
<li>Third news item</li>
</ul>
<ul class="marquee-group" aria-hidden="true">
<li>First news item</li>
<li>Second news item</li>
<li>Third news item</li>
</ul>
</div>
You'll see (hover it to pause):
min-width: 100% makes each copy at least as wide as the box, so even one short line fills it and no empty space shows. justify-content: space-around spreads short items out. aria-hidden="true" on the second copy means screen readers read each item once. The generator also gives links in that copy tabindex="-1", so the Tab key doesn't visit them twice. prefers-reduced-motion stops the animation for people who turned on “reduce motion” in their system settings.
Change the Speed
A CSS animation has a length in seconds, not a speed. animation: scroll 20s linear infinite means one loop
takes 20 seconds, however long the text is. So if you add more items, the text has further to go in the same time and
moves faster. That's why the generator shows the speed in pixels per second next to the seconds, and lets you type
either one. Start slow, then speed up only as long as you can still read it comfortably.
The old tag works the other way round: it moves scrollamount pixels every scrolldelay
milliseconds. scrollamount="6" and scrolldelay="85" (the defaults) make about 70 pixels a
second, whatever the length of the text.
Make It Pause
animation-play-state: paused freezes a CSS animation where it is. Put it on :hover to pause
while the mouse is over the bar. Pausing alone isn't enough when someone tabs to a link: the link might be outside the
window at that moment. So when a link has keyboard focus, the generator's code stops the bar and lays all the items out
standing still, with the focused link in view. For keyboard and phone users, add a Pause button. The generator uses a real checkbox styled as a button, so it works without
any JavaScript: Tab to it and press Space.
<style>
/* Pause while the mouse is over it */
.marquee:hover .marquee-group {
animation-play-state: paused;
}
/* A link reached with Tab: stand still and show every item,
so the focused link is never outside the window */
.marquee-viewport:has(a:focus-visible) .marquee-group {
animation: none;
flex-wrap: wrap;
}
.marquee-viewport:has(a:focus-visible) .marquee-group[aria-hidden="true"] {
display: none;
}
/* A Pause button: a real checkbox, styled as a button */
.marquee-pause-input:checked ~ .marquee-viewport .marquee-group {
animation-play-state: paused;
}
</style>
<div class="marquee">
<input type="checkbox" id="marquee-pause" class="marquee-pause-input">
<label for="marquee-pause" class="marquee-pause">Pause</label>
<div class="marquee-viewport">…the two groups…</div>
</div>
The old tag can only pause with a little JavaScript in its attributes:
<marquee onmouseover="this.stop()" onmouseout="this.start()">
Hover me to stop me
</marquee>
Some site builders and many email apps remove onmouseover, so test it where you paste it.
Scroll Text Up or Down
For a column of notices that moves up, use the same idea with flex-direction: column,
translateY() and a fixed height. The height is needed: without it the box grows to fit all
the items and there's nothing left to scroll. In the generator, pick the Up or Down arrow.
The code:
<style>
.notices {
--gap: 12px;
display: flex;
flex-direction: column;
gap: var(--gap);
height: 90px;
overflow: hidden;
padding: 0 12px;
border: 1px solid #d1d5db;
border-radius: 8px;
}
.notices-group {
display: flex;
flex-direction: column;
flex-shrink: 0;
justify-content: space-around;
gap: var(--gap);
min-height: 100%;
margin: 0;
padding: 0;
list-style: none;
animation: up 8s linear infinite;
}
@keyframes up {
to {
transform: translateY(calc(-100% - var(--gap)));
}
}
@media (prefers-reduced-motion: reduce) {
.notices-group {
animation: none;
}
}
</style>
<div class="notices">
<ul class="notices-group">
<li>Closed on Monday</li>
<li>New opening hours</li>
<li>Book club on Thursday</li>
</ul>
<ul class="notices-group" aria-hidden="true">
<li>Closed on Monday</li>
<li>New opening hours</li>
<li>Book club on Thursday</li>
</ul>
</div>
Make Your Marquee Accessible
- Give people a way to pause it. WCAG 2.2.2 (Pause, Stop, Hide) says that content that moves on its
own, lasts more than 5 seconds and sits next to other content needs a way to pause, stop or hide it. Hover alone only
helps mouse users, so turn on the Pause button.
- Respect “reduce motion”. Some people get dizzy or sick from moving things. The CSS from the generator stops for them and wraps the items so nothing is cut off. The old tag can't do this.
- Keep it slow and short. Moving text is harder to read than still text, especially for people who read slowly or use a screen magnifier.
- Check the contrast. Text needs at least 4.5:1 against its background (3:1 for large text). The contrast line in the tool checks it, or use the Color Contrast Checker.
- Don't hide important things in it. If people must read it (a closing date, a price change), also put it somewhere that stands still.
What This Generator Doesn't Do
- The pixels-per-second speed is an estimate for this preview. On your page the bar may be wider or narrower, and fonts differ a little between devices, so the real speed can be a bit different. Pictures are counted as squares, because the tool doesn't load them to measure.
- It makes one marquee at a time. For two on one page, give each a different class name, so their Pause buttons don't share an id.
- Links in the preview open in a new tab. Paths like
/sale point at this site there, so they'll only work once the code is on your own site. - Pictures load from the address you type. Some sites block their images from showing on other sites, and then you'll see the alt text instead.
- Many email apps don't run CSS animations, and support for the old tag varies, so test before you send a marquee in an email.
Need a button next to your bar? Try the HTML Button Generator. Pick colors with the
HTML Color Picker, and try the whole page in the HTML Editor.
Frequently Asked Questions
How do I make scrolling text in HTML?
There are two ways. The old one is the <marquee> tag: <marquee>Hello!</marquee> scrolls its text from right to left with no CSS at all. The modern way is a CSS animation: put the text in a box with overflow hidden and move it with @keyframes and transform: translateX(). The CSS way runs smoother, can pause, and stops for people who turn on “reduce motion”. This generator writes either one for you.
Is the <marquee> tag still supported?
Yes, every big browser still runs it, and they will for a long time because old pages use it. But it’s obsolete in the HTML standard, so validators flag it, and it has no built-in way to respect “reduce motion” or to pause from the keyboard. It’s fine for a quick test or a fun personal page. For a real site, use the Modern CSS code.
Why does my CSS marquee jump or leave a gap at the end?
When the text moves by its own width and starts again, there’s an empty stretch before it comes back, and then it jumps. The fix is to put the items in the code twice, side by side, and move both by exactly one copy’s width plus the gap. When the loop restarts, the second copy is exactly where the first one began, so you can’t see the jump. The second copy gets aria-hidden="true" so screen readers don’t read everything twice. The generator does all of this for you.
How do I make a marquee pause on hover?
With CSS, add .marquee:hover .marquee-group { animation-play-state: paused; }. The generator also stops the bar and shows every item standing still while a link inside has keyboard focus, so the focused link is always in view. With the old tag, add onmouseover="this.stop()" onmouseout="this.start()" to the <marquee> tag. Hover doesn’t help keyboard or phone users, so also turn on the Pause button in the generator.
How do I change the speed of a marquee?
In CSS the speed is the time for one loop, like animation: marquee-scroll-x 20s linear infinite. More seconds is slower. Because it’s a time, longer text moves faster in the same number of seconds, so check it again after you change the text. With the old tag, scrollamount is how many pixels it moves per step (the default is 6) and scrolldelay is the wait between steps in milliseconds (the default is 85, and browsers won’t go below 60).
How do I make text scroll up or down?
Pick the Up or Down arrow under Direction. Vertical scrolling needs a fixed height, because the box has to know how much to show at once, so the generator adds one (you can change it). In the CSS version the items stack in a column and move with translateY(). With the old tag it’s direction="up" plus a height in the style.
Are marquees bad for accessibility?
They can be. Moving text is hard to read for many people and can make some feel ill. WCAG 2.2.2 (Pause, Stop, Hide) says that text that moves on its own for more than 5 seconds needs a way to pause, stop or hide it. The CSS from this generator stops moving for people who turn on “reduce motion”, can pause on hover, and can include a Pause button that works with the keyboard. Also don’t put anything people must read only in a moving bar.
Can I put links, emoji or images in a marquee?
Yes. Emoji are just text, so type them in. For a link, write the text, a bar and the address: Big sale | https://example.com/sale. For a picture, start the line with image: and add the alt text after a bar: image: https://example.com/logo.png | Shop logo. Picture addresses must start with https://, and links can’t be javascript: or data: addresses, so nothing unsafe ends up in your code.