The legacy <marquee> element uses the direction attribute to choose the movement direction. The historical values are left, right, up, and down. If direction is omitted, the usual default is left.
<marquee> is obsolete and should not be used in new HTML. The examples below remain useful when maintaining older pages, followed by modern CSS alternatives.<marquee direction="left">Scrolling text</marquee>
direction="left" moves the content from right to left. This is also the normal default direction when the attribute is omitted.
<marquee direction="left">
This is an example of Marquee
</marquee>
direction="right" moves the content from left to right.
<marquee direction="right">
This is an example of Marquee
</marquee>
direction="up" moves the content vertically upward. A fixed height was commonly used on old pages to define the visible marquee area.
<marquee direction="up" height="80">
This is an example of Marquee direction = up
</marquee>
direction="down" moves the content vertically downward.
<marquee direction="down" height="80">
This is an example of Marquee direction = down
</marquee>
direction with presentational attributes such as bgcolor, height, or inline font styling. These may still appear in old code, but CSS should control presentation in new work.For new projects, use semantic HTML and CSS animation. The movement direction comes from the start and end values used in transform: translateX() or translateY().
<div class="ticker">
<p class="move-left">Moving from right to left</p>
</div>
<style>
.ticker { overflow: hidden; }
.move-left {
white-space: nowrap;
animation: moveLeft 8s linear infinite;
}
@keyframes moveLeft {
from { transform: translateX(100%); }
to { transform: translateX(-100%); }
}
</style>
For movement in the opposite direction, swap the transform values:
@keyframes moveRight {
from { transform: translateX(-100%); }
to { transform: translateX(100%); }
}
Vertical movement uses translateY() in the same way:
@keyframes moveUp {
from { transform: translateY(100%); }
to { transform: translateY(-100%); }
}
@keyframes moveDown {
from { transform: translateY(-100%); }
to { transform: translateY(100%); }
}
Automatically moving content can be distracting and may be difficult for some users to read. Important information should remain available even when animation is disabled, and essential controls should not depend on motion.
Respect the user's reduced-motion preference when animation is not essential:
@media (prefers-reduced-motion: reduce) {
.move-left, .move-right, .move-up, .move-down {
animation: none;
}
}
Keep <marquee> only for maintaining legacy pages. Use CSS animation when directional movement is truly needed.
Do not rely on bgcolor, old alignment attributes, or other presentational HTML. Use CSS.
Users should not have to chase important information across the screen. Prefer static content or provide a way to pause motion when animation is necessary.
direction changes where marquee content moves. Legacy scrollamount and scrolldelay affect movement speed instead.
The legacy values are left, right, up and down.
The usual default is left when the direction attribute is omitted.
No. Marquee is obsolete and should not be used for new HTML. CSS animation is the modern alternative.
Animate transform from translateX(100%) to translateX(-100%) inside an overflow-hidden container.
Use a CSS animation with translateY() to move the element upward or downward.
Use the prefers-reduced-motion media query to disable or simplify non-essential animation.
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.
| sabir malik | 02-02-2012 |
| very nice effort | |
| Mayesh Mohapatra | 22-11-2013 |
| Very Very Useful for students like me | |
| varun | 03-03-2014 |
| How to change text color when mouse hover | |
| shahid | 26-10-2014 |
| very nice tips about marquu thanks | |
| Friday Moses | 27-04-2015 |
| I am happy to arrive at this tutorial site, may God bless u for this wonderful support for new commers like me. | |
| ABDULLAH WASEER | 11-09-2015 |
| learn to good got a good idea | |
| Deepak Prasad | 04-11-2015 |
| Is it possible to move marquee in multiple directions and not a straight line | |
| Uche E | 02-09-2016 |
| dont we have a zig zag direction for marquee? | |
| smo1234 | 03-09-2016 |
| There is no zig zag in direction but you can keep two marquee tags one after the other and give them opposite directions. You can match their speed to give cross effect. | |
| MAHESH KUMAR | 17-11-2016 |
| Very nice tips,about marquee.Very very thanks sir................. | |
| divya | 31-10-2018 |
| can i set multiple direction in marquee tag? and in each direction can in set different timings? | |
| smo1234 | 31-10-2018 |
| May be by using DOM this can be done, by using simple HTML not possible. | |
19-01-2022 | |
| its very usefull | |