Stop and Start HTML Marquee on Mouse Over

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.

For new pages: <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>
HTML marquee tag to stop and start scroll by using mouse over and mouse out events in Div

Pause Legacy Marquee on Mouse Over Top ↑

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.

News 1   News 2   News 3   News 4   More news here
<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.

Legacy note: 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.

Pause While the Mouse Button Is Held Top ↑

Older marquee pages can also pause while the pointer button is held down and resume on release.

News 1   News 2   News 3   News 4   More news here
<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.

PHP | SQL | plus2net Home
<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>

Start and Stop a Legacy Marquee with Buttons Top ↑

The marquee DOM interface also exposes start() and stop(), so existing marquee code can be controlled with ordinary buttons.

News 1   News 2   News 3   News 4   More news here
<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.

Modern CSS: Pause Scrolling on Hover or Focus Top ↑

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 &nbsp; News 2 &nbsp; 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.

Accessible Pause and Resume Button Top ↑

A button can toggle a CSS class instead of calling obsolete marquee methods.

News 1   News 2   News 3   News 4   More news here
<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>

Accessibility and Reduced Motion Top ↑

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.

Common Marquee Mouseover Mistakes Top ↑

Using marquee for a new ticker Top ↑

<marquee> and its start()/stop() interface are legacy features. Use CSS animation for new work.

Supporting only mouse hover Top ↑

Hover-only behavior does not provide an equivalent control for keyboard or touch users. Add focus behavior and, where useful, a visible pause control.

Putting important links in continuously moving content Top ↑

Moving targets are harder to read and activate. Keep essential navigation available outside the animation or ensure the motion can be paused easily.

Using obsolete presentation attributes Top ↑

Old marquee code often uses bgcolor and inline font styling. Use CSS for presentation when maintaining the page.

Changing a button label without exposing state Top ↑

If one button toggles animation state, update its accessible state as well as its visible text. aria-pressed is useful for a toggle button.

Frequently Asked Questions Top ↑

Q1: How did old HTML marquees stop on mouse over?

Legacy pages commonly called the marquee stop() method on mouseover and start() on mouseout.

Q2: Are marquee start() and stop() still recommended?

No. They belong to the obsolete marquee interface and should be kept only for maintaining legacy pages.

Q3: How do I pause a CSS animation on hover?

Set animation-play-state:paused on the animated element when its container matches :hover.

Q4: Is hover enough for an accessible pause control?

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.

Q5: How can JavaScript pause a modern ticker?

Toggle a class that sets animation-play-state to paused instead of calling marquee start() and stop().

Q6: How should reduced-motion preferences be handled?

Use prefers-reduced-motion to disable or simplify non-essential animation while keeping the information available.


HTML Marquee Tag Marquee Repeat Marquee Behavior



plus2net.com







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



We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer