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.
<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.
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.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:
<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.
behavior="slide" moves the content toward the destination edge and then stops instead of repeating continuously.
Legacy rendered example:
<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.
behavior="alternate" makes the moving content reverse direction when it reaches an edge.
Legacy rendered example:
<marquee style="background:#000080; color:#fff" behavior="alternate">
This is an Example Marquee (Behavior: Alternate)
</marquee>
The historical direction attribute could be combined with behavior="alternate". This example moves vertically within an 80-pixel-high marquee area.
<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.
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;
}
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.
The element is deprecated. Preserve it only when maintaining legacy content; use CSS animation for new work.
Attributes such as bgcolor, old alignment attributes and marquee-specific movement controls should not be presented as modern HTML styling techniques.
Deprecated behavior is not a good compatibility contract for new interfaces. Build the intended effect with supported CSS instead.
If motion is not essential, reduce or remove it with @media (prefers-reduced-motion: reduce).
It continuously moves the marquee content across its area and starts the movement again. It was also the default marquee behavior.
Slide moves the content toward an edge and stops, while alternate reverses direction when the content reaches an edge.
No. The marquee element is deprecated and should not be used for new projects. CSS animation is the preferred approach.
Use a CSS animation and set animation-direction to alternate so each animation cycle reverses direction.
Keep important information available without motion and use prefers-reduced-motion to reduce or disable non-essential animation for users who request it.
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.
| 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” | |