HTML Marquee Behavior: scroll, slide and alternate

The legacy <marquee> element used the behavior attribute to control what happened when moving content reached an edge. Its three commonly used values were scroll, slide and alternate.

Modern HTML note: <marquee> is deprecated and should not be used in new projects. The examples below are preserved for understanding older pages. For new work, use CSS animation and respect the user's reduced-motion preference.
<marquee behavior="scroll">Scrolling text</marquee>
<marquee behavior="slide">Sliding text</marquee>
<marquee behavior="alternate">Alternating text</marquee>

scroll repeats the movement, slide moves toward an edge and stops, and alternate reverses direction at the edges. Browser support for <marquee> is legacy behavior and should not be the basis of a new interface.

Examples of legacy marquee scroll, slide and alternate behavior

Marquee behavior values Top ↑

The historical behavior attribute accepted these values:

  • scroll: moves across the marquee area and starts again; this was the default behavior.
  • slide: moves toward the destination edge and stops.
  • alternate: reverses direction when it reaches an edge.
HTML marquee tag to scroll or alternate text or image on web page with various speed and direction

Scroll behavior Top ↑

behavior="scroll" continuously moves the content across the marquee area and then starts again. It was the default when the behavior attribute was omitted.

Legacy rendered example:

This is an Example Marquee (Behavior: Scroll)
<marquee style="background:#000080; color:#fff" behavior="scroll">
  This is an Example Marquee (Behavior: Scroll)
</marquee>

The original bgcolor presentation attribute has been replaced with CSS in the example above. This does not make <marquee> modern; it only avoids teaching an additional obsolete presentation attribute.

Slide behavior Top ↑

behavior="slide" moves the content toward the destination edge and then stops instead of repeating continuously.

Legacy rendered example:

This is an Example Marquee (Behavior: Slide)
<marquee style="background:#000080; color:#fff" behavior="slide">
  This is an Example Marquee (Behavior: Slide)
</marquee>

Older tutorials sometimes described this as Internet Explorer-only behavior. That historical browser note is no longer useful guidance: the element itself is deprecated, so new pages should use CSS rather than depending on legacy marquee compatibility.

Alternate behavior Top ↑

behavior="alternate" makes the moving content reverse direction when it reaches an edge.

Legacy rendered example:

This is an Example Marquee (Behavior: Alternate)
<marquee style="background:#000080; color:#fff" behavior="alternate">
  This is an Example Marquee (Behavior: Alternate)
</marquee>

Alternate behavior with vertical direction Top ↑

The historical direction attribute could be combined with behavior="alternate". This example moves vertically within an 80-pixel-high marquee area.

direction="up" behavior="alternate"
<marquee style="height:80px; background:#000080; color:#fff" direction="up" behavior="alternate">
  direction="up" behavior="alternate"
</marquee>

For new projects, create vertical or horizontal movement with CSS animation instead of the obsolete direction and behavior attributes.

Modern CSS alternative Top ↑

CSS animation provides more control and keeps presentation out of HTML. The example below creates a continuous horizontal ticker-like effect without <marquee>.

<div class="ticker">
  <span>Latest tutorial update</span>
</div>

<style>
.ticker {
  overflow: hidden;
  white-space: nowrap;
}
.ticker span {
  display: inline-block;
  padding-left: 100%;
  animation: ticker 8s linear infinite;
}
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}
@media (prefers-reduced-motion: reduce) {
  .ticker span {
    animation: none;
    padding-left: 0;
  }
}
</style>

To imitate a one-time slide, use a single animation iteration and retain the final state with animation-fill-mode: forwards. To imitate alternate, CSS supports animation-direction: alternate.

.slide-once {
  animation: moveIn 3s linear 1 forwards;
}
.alternate-motion {
  animation: moveSide 3s linear infinite alternate;
}

Accessibility and reduced motion Top ↑

Automatically moving content can be distracting or uncomfortable for some users. For non-essential movement, provide a static experience when the user has enabled a reduced-motion preference. If moving content contains important information, make sure the same information remains available when animation is stopped.

Do not rely on motion alone to communicate meaning, and avoid making important text continually move when a static presentation would work just as well.

Common mistakes Top ↑

Using marquee in new production code Top ↑

The element is deprecated. Preserve it only when maintaining legacy content; use CSS animation for new work.

Combining several obsolete presentation attributes Top ↑

Attributes such as bgcolor, old alignment attributes and marquee-specific movement controls should not be presented as modern HTML styling techniques.

Assuming every browser will reproduce legacy behavior identically Top ↑

Deprecated behavior is not a good compatibility contract for new interfaces. Build the intended effect with supported CSS instead.

Ignoring reduced-motion preferences Top ↑

If motion is not essential, reduce or remove it with @media (prefers-reduced-motion: reduce).

Frequently Asked Questions Top ↑

Q1: What does behavior="scroll" do in a marquee?

It continuously moves the marquee content across its area and starts the movement again. It was also the default marquee behavior.

Q2: What is the difference between slide and alternate?

Slide moves the content toward an edge and stops, while alternate reverses direction when the content reaches an edge.

Q3: Is the HTML marquee tag still recommended?

No. The marquee element is deprecated and should not be used for new projects. CSS animation is the preferred approach.

Q4: How can CSS imitate alternate marquee behavior?

Use a CSS animation and set animation-direction to alternate so each animation cycle reverses direction.

Q5: How should moving text handle accessibility?

Keep important information available without motion and use prefers-reduced-motion to reduce or disable non-essential animation for users who request it.


HTML Marquee Tag Marquee Scroll Direction Mouseover Scroll Control



plus2net.com







Vijay

10-04-2012

Very usefula nd to the point thanks
agus kaosgrosir

06-09-2012

I see behavior=slide only stop in the left. What happened ? Regards
Harrshit Gill

04-03-2014

This is really useful
tshepiso bareetseng

25-06-2014

how do i scrool to the right
smo

25-06-2014

You can give direction like direction='right'
manju

30-06-2014

what is the formula scrolling from left side
Muhammad irfan

24-07-2015

realy nice tips
irfan

17-03-2017

how we can make a text start from right corner and stop at center ?
smo1234

20-03-2017

This part is added now. This is not a direct solution but can be used.
Aditya Soni

25-01-2019

The 'Alternate' Behavior is not working in Up and Down direction . Can you solve this?
smo1234

08-02-2019

This part is added.

07-12-2019

in your website have a fantastic example that is very benefits ,thanks

24-12-2020

I figured out how to make it scroll up but it always starts from the very bottom of the page
can you add a section for scrolling up but starting from the very top?

Thanks

17-06-2021

Many thanks, clarified a doubt I had.

13-10-2021

Tks a lot

08-01-2024

Behevior=“slide”



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