Legacy <marquee> elements expose start() and stop() methods. Older pages often combine these methods with mouse events so scrolling pauses while the pointer is over the content and resumes when the pointer leaves.
<marquee> is obsolete. Keep the examples below when maintaining legacy code, but use CSS animation and accessible pause controls for new scrolling or ticker effects.<marquee id="scroll_news"
onmouseover="this.stop();"
onmouseout="this.start();">
News 1 News 2 News 3 News 4
</marquee>
The original technique uses mouse events with the marquee's legacy stop() and start() methods. The following live example remains useful when maintaining old pages.
<marquee id="scroll_news"
onmouseover="this.stop();"
onmouseout="this.start();">
News 1 News 2 News 3 News 4
</marquee>
See the existing JavaScript tutorial on mouse over and mouse out events for event basics.
mouseover and mouseout can fire as the pointer moves between descendants. For new interactive components, JavaScript often uses mouseenter/mouseleave or CSS :hover, depending on the behavior required.Older marquee pages can also pause while the pointer button is held down and resume on release.
<marquee
onmousedown="this.stop();"
onmouseup="this.start();">
News 1 News 2 News 3 News 4
</marquee>
This is a legacy interaction example rather than a recommended control pattern. A dedicated Pause/Resume button is clearer and works beyond mouse-only interaction.
The original page demonstrates links inside moving content. Those links are preserved below, although continuously moving links can be harder to select and activate accurately.
<marquee onmouseover="this.stop();" onmouseout="this.start();">
<a href="../php_tutorial/site_map.php">PHP</a> |
<a href="../sql_tutorial/site_map.php">SQL</a> |
<a href="../">plus2net Home</a>
</marquee>
The marquee DOM interface also exposes start() and stop(), so existing marquee code can be controlled with ordinary buttons.
<marquee id="scroll_news3">News items</marquee>
<button type="button"
onclick="document.getElementById('scroll_news3').stop();">
Stop Scrolling
</button>
<button type="button"
onclick="document.getElementById('scroll_news3').start();">
Start Scrolling
</button>
The original page also used getElementById() with one button whose label changed between Start and Stop. That approach can still be found in old code, but new components should separate state from the displayed label and expose control state accessibly.
For a new ticker effect, use CSS animation instead of <marquee>. The animation-play-state property can pause the animation and resume it from the same point.
<div class="ticker">
<div class="ticker-content">
News 1 News 2 News 3
</div>
</div>
<style>
.ticker {
overflow: hidden;
}
.ticker-content {
white-space: nowrap;
animation: tickerMove 12s linear infinite;
}
.ticker:hover .ticker-content,
.ticker:focus-within .ticker-content {
animation-play-state: paused;
}
@keyframes tickerMove {
from { transform: translateX(100%); }
to { transform: translateX(-100%); }
}
</style>
Hover support helps mouse users, while :focus-within can pause the animation when a keyboard user focuses a link or control inside the ticker. A visible button is still the clearest cross-input control when users need to stop motion.
A button can toggle a CSS class instead of calling obsolete marquee methods.
<button type="button" id="tickerToggle" aria-pressed="false">
Pause animation
</button>
<script>
const ticker = document.getElementById('tickerDemo');
const button = document.getElementById('tickerToggle');
button.addEventListener('click', () => {
const paused = ticker.classList.toggle('is-paused');
button.setAttribute('aria-pressed', paused ? 'true' : 'false');
button.textContent = paused ? 'Resume animation' : 'Pause animation';
});
</script>
Do not make hover the only way to pause important moving content. Keyboard, touch and assistive-technology users also need access to the information and controls. Important news or status text should remain available in a static form when motion is disabled.
@media (prefers-reduced-motion: reduce) {
.ticker-content {
animation: none;
transform: none;
}
}
For motion that is purely decorative, disabling the animation is usually better than forcing users to pause it manually.
<marquee> and its start()/stop() interface are legacy features. Use CSS animation for new work.
Hover-only behavior does not provide an equivalent control for keyboard or touch users. Add focus behavior and, where useful, a visible pause control.
Moving targets are harder to read and activate. Keep essential navigation available outside the animation or ensure the motion can be paused easily.
Old marquee code often uses bgcolor and inline font styling. Use CSS for presentation when maintaining the page.
If one button toggles animation state, update its accessible state as well as its visible text. aria-pressed is useful for a toggle button.
Legacy pages commonly called the marquee stop() method on mouseover and start() on mouseout.
No. They belong to the obsolete marquee interface and should be kept only for maintaining legacy pages.
Set animation-play-state:paused on the animated element when its container matches :hover.
No. Hover does not cover keyboard and touch interaction. Support focus where relevant and provide a visible Pause/Resume control when users need to stop the motion.
Toggle a class that sets animation-play-state to paused instead of calling marquee start() and stop().
Use prefers-reduced-motion to disable or simplify non-essential animation while keeping the information available.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| Balaji | 20-03-2013 |
| Hay... This is amazing for bigiiners..!!! Thanks...!!! | |
| sekhar | 20-06-2014 |
| nice explanation | |
| gidion | 15-08-2014 |
| something good | |
| Joe | 17-10-2014 |
| Very Nice | |
| gobolin | 23-11-2014 |
| hey guys, nice feature, but is there a way to have a single button to maybe on first click start a marquee and on second stop it, then start and stop and on and on? thanks :) | |
| smo | 26-11-2014 |
| By adding JavaScript function it can be done. Example is added. | |
| Muhammad hussain | 06-04-2015 |
| Its amazing work and i love it it is running nicely on my blog thanks for sharing | |
| swapnaja | 03-08-2015 |
| Nice One .Helpfull | |
| mantoo kumar | 17-06-2016 |
| This is very useful for begiiners. Nice | |
| shukrab khan | 01-07-2016 |
| its just amazing some of marquee are not working in both browsers but its work for me in both. Thank you. | |
| pranati | 24-08-2016 |
| Nice One .Helpfull | |
15-05-2021 | |
| Wow Bro Your Animation is Very Helpfull | |