- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <marquee> Tag
HTML Tags
HTML <marquee> Tag
<marquee>scrolls its content across the screen. It was never part of any HTML standard, it is listed as obsolete in the current one, and you should not use it on a new page. It is still worth understanding, partly because it still works in every browser, partly because the CSS replacement teaches you something useful.
What it does
Internet Explorer added <marquee> in 1995 and every other browser copied it because so many pages used it. Wrap text in it and the text slides from right to left, forever.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>marquee</title>
</head>
<body>
<marquee>Breaking: this text has been scrolling since 1995.</marquee>
<marquee direction="up" height="60" scrollamount="2">Upwards, slowly.</marquee>
<marquee behavior="alternate" bgcolor="#fef3c7">Bouncing between the edges.</marquee>
</body>
</html>| Attribute | What it did | Values |
|---|---|---|
| direction | Which way the content moves | left (default), right, up, down |
| behavior | How it moves | scroll (default), slide (stops at the edge), alternate (bounces) |
| scrollamount | Pixels moved per step | A number; default 6 |
| scrolldelay | Milliseconds between steps | A number; default 85 |
| loop | How many times to scroll | A number, or -1 for forever |
| width, height, bgcolor | Size and background | Pixels, percentages, a colour |
Why it was dropped
- It was never standard. It came from one vendor and was reverse-engineered by the rest. Its behaviour differs slightly between browsers and always has.
- Moving text is hard to read. Users have to wait for the part they missed to come round again. People with reading or attention difficulties often cannot read it at all.
- It ignores user preferences. Operating systems let people ask for reduced motion.
<marquee>does not listen. - Presentation belongs in CSS. The same argument that retired
<font>and<center>: HTML describes what content is, CSS describes how it looks and moves.
The HTML Living Standard's wording is that browsers "must" keep supporting it for old pages, and authors "must not" use it. So it will not disappear from your browser: it just should not appear in your code.
How to do it properly: CSS animation
If a ticker really is what the design calls for (a news bar, a sponsor strip) build it with a CSS keyframe animation. You get the same effect, control over speed and easing, and you can switch it off for people who asked for less motion.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS ticker</title>
<style>
.ticker {
overflow: hidden;
white-space: nowrap;
background: #0f172a;
color: white;
padding: 8px 0;
}
.ticker-track {
display: inline-block;
margin: 0;
padding-left: 100%; /* start just off the right edge */
animation: ticker 18s linear infinite;
}
@keyframes ticker {
to { transform: translateX(-100%); }
}
.ticker:hover .ticker-track {
animation-play-state: paused; /* let people read it */
}
@media (prefers-reduced-motion: reduce) {
.ticker-track { animation: none; padding-left: 16px; }
}
</style>
</head>
<body>
<div class="ticker" aria-label="Latest updates">
<p class="ticker-track">
Results day is 12 October • New CSS Grid chapter published • Practice plan now ₹99 a month
</p>
</div>
</body>
</html>Three things here that <marquee> could never do: it pauses on hover so the text can actually be read, it stops entirely when the user has asked for reduced motion, and the speed is one number (18s) rather than two interacting ones.
Common mistakes
Using it because it is quick
It is one line and the CSS version is fifteen. But the one line fails HTML validation, fails accessibility checks, and will be the first thing anyone reviewing the page asks you to remove. The fifteen lines are copy-and-paste once.
Expecting the CSS version to pause when it reaches the end
animation: … infinite restarts the moment the text leaves the left edge, which can look like a jump. If you want a gap before it comes round again, make the track wider than the text (padding on the right) or add a pause with a second keyframe at, say, 90%.
Animating left instead of transform
Older tutorials animate left: 100% to left: -100%. That forces the browser to recalculate layout on every frame and stutters on phones. transform: translateX() runs on the compositor and stays smooth.
Browser support
<marquee> works in every current browser for the sake of old pages. The CSS replacement (keyframe animations, transform, and prefers-reduced-motion) is supported everywhere too.
Related chapters
- Deprecated HTML tags: the full list and what replaced each one
- CSS animations
- User preference media queries:
prefers-reduced-motionand friends <blink>: the other tag nobody misses
HTML <marquee> Tag exercises
Use text that stands still
The marquee element is obsolete. Write a paragraph with the class news that says Big sale this week.
Result
