The HTML <marquee> tag is used for horizontally or vertically scrolling text or images on a web page.
Although the <marquee> tag is deprecated and not recommended for modern web design, it can be useful for simple animations.
Alternatives to the <marquee> tag are CSS animations and JavaScript, which offer greater flexibility and better support across all browsers.
Here's how you can use the <marquee> tag with various attributes:
In the following examples, using the DIRECTION attribute, we will show examples of scrolling text and images.
<marquee direction="left" scrollamount="20">
<p>WELLCOME to IT PRESENT</p>
</marquee>
<marquee direction="right" scrollamount="20">
<p>WELLCOME to IT PRESENT</p>
</marquee>
<marquee direction="up">
<p>WELLCOME to IT PRESENT</p>
</marquee>
<marquee direction="down">
<p>WELLCOME to IT PRESENT</p>
</marquee>
<marquee behavior="alternate" scrollamount='20'>
<p>WELLCOME to IT PRESENT</p>
</marquee>
<marquee direction="up" height="300" behavior="alternate">
<marquee behavior="alternate">
<p>WELLCOME</p>
</marquee>
</marquee>
<marquee direction='left' scrollamount='25'>
<img src="heart.jpg">
<img src="heart.jpg">
<img src="heart.jpg">
<img src="heart.jpg">
<img src="heart.jpg">
<img src="heart.jpg">
</marquee>
Using CSS for scrolling text or images is a more modern and flexible approach. Here's an example of a CSS animation that mimics the <marquee> effect:
<!DOCTYPE html>
<html>
<head>
<style>
@keyframes marquee {
0% { transform: translateX(100%); }
100% { transform: translateX(-100%); }
}
.marquee {
display: inline-block;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
animation: marquee 10s linear infinite;
}
</style>
</head>
<body>
<div class="marquee">
<p>WELCOME to IT PRESENT</p>
</div>
</body>
</html>
result:
Using CSS animations gives you better control over animations and ensures compatibility with all modern browsers.