Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is marquee tag in html?
2.1.
Example
2.2.
HTML
3.
Global Attributes
4.
Specific Attributes
5.
Event Attributes
6.
Supported Browsers
7.
Frequently Asked Questions
7.1.
What is marquee direction?
7.2.
What is marquee in HTML with example?
7.3.
Is marquee still used in HTML?
7.4.
What is a marquee display?
8.
Conclusion
Last Updated: Aug 2, 2024
Easy

Marquee Tag in HTML

Author Ravi Khorwal
0 upvote

Introduction

The HTML marquee tag is a legacy feature that enables text or images to scroll or slide horizontally or vertically across a web page, creating a moving effect. Despite being outdated and generally discouraged in modern web design due to its lack of accessibility and control, it continues to intrigue with its simple way of adding motion to web content.

Marquee Tag in HTML

In this blog, we will learn about marquee tag in HTML.  We will learn about core concepts, real-world applications and much more. 

What is marquee tag in html?

The HTML <marquee> tag is used to create scrolling images or text in web pages. It helps to scroll either from horizontally left to right or right to left, or vertically bottom to top or top to bottom.

Example

Let us look at the example to understand marquee tag in HTML:

  • HTML

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Marquee Example</title>
</head>
<body>

<h1>Welcome to the Marquee Example</h1>

<marquee behavior="scroll" direction="left">
This text is scrolling from right to left using the marquee tag.
</marquee>

</body>
</html>

Explanation:

In this example, we have created a webpage with a heading and a <marquee> tag that makes the enclosed text scroll from right to left. The behavior attribute defines the scrolling behavior, and the direction attribute specifies the scrolling direction.

Output:

output

Global Attributes

The <marquee> tag in HTML supports various global attributes that can be used to modify its behavior. Here are some common global attributes for the <marquee> tag:

  1. id: Specifies a unique id for the element.
  2. class: Assigns one or more class names to the element, which can be used for styling.
  3. style: Defines inline CSS styles for the element.
  4. title: Adds a title to the element, often displayed as a tooltip.
  5. lang: Specifies the language of the element's content.
  6. dir: Sets the text direction, such as "ltr" for left-to-right or "rtl" for right-to-left.

These attributes are part of the global attributes applicable to most HTML elements and can be used with the <marquee> tag for customization and styling.

Specific Attributes

There are some specific attributes that provide control over the appearance and behavior of the <marquee> element.

AttributeValue(s)Description
behaviorscroll, slide, alternateDefines the scrolling behavior of the marquee.
directionleft, right, up, downSets the direction of the scrolling.
scrollamountNumeric valueSpecifies the speed of the scrolling.
scrolldelayNumeric valueDefines the delay between each scroll iteration.
widthNumeric value or percentageSets the width of the marquee.
heightNumeric value or percentageSets the height of the marquee.
loopNumeric value or infiniteSpecifies the number of times the marquee should loop.

Event Attributes

The <marquee> tag in HTML supports various event attributes that allow you to execute JavaScript code in response to specific events. Here are some commonly used event attributes for the <marquee> tag:

  • onstart: <marquee onstart="script">, it defines a script to be run when the marquee starts scrolling.
  • onfinish: <marquee onfinish="script">, it specifies a script to be run when the marquee has finished scrolling.
  • onmouseover: <marquee onmouseover="script">, it defines a script to be run when the mouse pointer is over the marquee.
  • onmouseout: <marquee onmouseout="script">, it specifies a script to be run when the mouse pointer leaves the marquee.

Supported Browsers

The <marquee> tag is supported by most web browsers, but it's considered outdated, and its usage is discouraged. It may not be fully supported in some modern browsers. For better compatibility and adherence to web standards, CSS animations or JavaScript are recommended over the <marquee> tag.

The browsers that are mentioned below still supports the <marquee> tag:

  • Chrome
  • Firefox
  • Safari, and 
  • Microsoft Edge 

Frequently Asked Questions

What is marquee direction?

Marquee direction specifies the direction in which the content within a marquee element scrolls. Common values include "left," "right," "up," and "down." It controls the movement of text or images, enhancing visual dynamics on a webpage.

What is marquee in HTML with example?

The <marquee> tag in HTML is used for creating scrolling content. Example: <marquee behavior="scroll">Scrolling Text</marquee>.

Is marquee still used in HTML?

The <marquee> tag is outdated, and its usage is discouraged in modern web development. CSS is preferred for achieving similar effects.

What is a marquee display?

A marquee display refers to the visual effect of scrolling content, commonly seen in older websites, where text or images move horizontally or vertically.

Conclusion

The marquee tag in HTML offers a glimpse into the early days of web design, showcasing how simple effects were achieved. However, as web design has matured, the marquee tag has been left behind in favor of more robust, accessible, and standards-compliant methods like CSS animations and JavaScript.

You can refer to our guided paths on the Coding Ninjas. You can check our course to learn more about DSADBMSCompetitive ProgrammingPythonJavaJavaScript, etc. 

Also, check out some of the Guided Paths on topics such as Data Structure and AlgorithmsCompetitive ProgrammingOperating SystemsComputer Networks, DBMSSystem Design, etc., as well as some Contests, Test Series, and Interview Experiences curated by top Industry Experts.

Live masterclass