HTML <marquee> Tag: Usage, Attributes, and Examples

By Cristian G. Guasch •  Updated: 09/25/23 •  9 min read

HTML has a wide range of tags, each offering unique functionalities to enhance the design and interactivity of web pages. The <marquee> tag, although not commonly used in modern web development due to its deprecation, is one such element that caught my attention. It’s known for its distinctive scrolling effect on text or images.

The HTML <marquee> tag was once widely embraced for creating scrollable text and images within a webpage. However, because it’s no longer part of the HTML5 specifications, it may not work across all browsers today. Yet understanding how this tag works can provide insight into the evolution of web design practices.

In this article, I’ll delve into the usage and attributes of the HTML <marquee> tag along with examples to better illustrate its application. Whether you’re new to HTML or an experienced developer looking to broaden your knowledge base, this deep dive into the <marquee> tag promises valuable insights. So let’s roll up our sleeves and get started!

Understanding the HTML <marquee> Tag

Delving deeper into the world of HTML, we’ll discover a handy little gem known as the <marquee> tag. This vintage piece of HTML coding can create a scrolling text or image effect on your webpage. It’s like hanging a digital banner that scrolls across your screen.

Let’s say you’re running an online sale and want to grab your visitors’ attention. You could use the <marquee> tag to make a scrolling announcement banner at the top of your webpage. Here’s how it might look in code:

<marquee>Welcome to our annual summer sale! Enjoy discounts up to 50% off!</marquee>

But be warned, not all web browsers support this classic HTML tag due its deprecation in HTML5. So, while it’s fun to play around with, I wouldn’t recommend relying on it for key website elements.

On top of basic scrolling text effects, there are also several attributes that can modify how the <marquee> element behaves. For instance,

It’s worth mentioning though that these attributes aren’t standardized across all browsers either, so they may behave differently depending on who is viewing your site.

Now let me draw attention towards some common mistakes made while using <marquee> tag:

  1. Not closing the marquee tag: Every opened marquee must be closed properly else it may lead to unwanted consequences.
  2. Using deprecated attributes: Some old version attributes like scrollamount and scrolldelay have been deprecated and won’t work in modern browsers.
  3. Overuse: Marquee can be distracting if overused. So use it sparingly and only when necessary.

To wrap up this part, while the <marquee> tag comes with its fair share of issues, it can still add a fun little twist to your webpage through scrolling text or images. Just remember to test it out on different browsers before going public!

How to Use the HTML <marquee> Tag

Diving right in, let’s demystify the use of the HTML <marquee> tag. This tag is a bit of an old-school tool used for creating scrolling text or images on a webpage. It’s important to note though that it isn’t recommended for modern websites due to its deprecation by W3C.

Here’s how you can implement this tag:

<marquee>This is some scrolling text!</marquee>

In this example, This is some scrolling text! would scroll across your webpage from right to left. But wait! There are other attributes you can add to customize the behavior and appearance of your marquee.

The direction attribute lets you control which way your content scrolls. You have four options: “up”, “down”, “left”, and “right”. If you want your text to scroll upwards, just add direction="up":

<marquee direction="up">This is some scrolling text!</marquee>

Now let’s talk speed. The scrollamount attribute allows you to adjust how quickly your content moves across the screen. Just remember, higher values mean faster movement!

<marquee scrollamount="10">This is some scrolling text!</marquee>

A common mistake people make when using <marquee>? They don’t close it properly! Always ensure there’s a closing </marquee> tag after your content.

Keep in mind:

Despite these caveats, understanding how things like <marquee> work can provide valuable insight into how HTML has evolved over the years, and why certain practices have fallen out of favor.

Exploring Attributes of the <marquee> Tag in HTML

Diving right into our topic, let’s start with a quick refresh on what exactly we’re dealing with here. The <marquee> tag in HTML is something of an old-school feature, used to create scrolling text or images on web pages. It might not be as popular today, but it certainly has its uses and is worth understanding.

So what makes up a marquee? Well, it’s all about the attributes. These are the bits of information that control how your marquee behaves. Here are some key ones you’ll likely encounter:

Let me show you an example –

<marquee direction="left" behavior="alternate" loop="10" bgcolor="#FFD700">Gold Rush!</marquee>

In this case, we’ve got text scrolling from left to right until it hits 10 loops, and all on a golden background! Pretty nifty stuff.

But hold on! Before getting too carried away with marquees and their attributes, there’s one thing I need to mention: they’re not officially part of HTML5 specifications. That means while they may work now, future browser updates could cease support for them altogether.

Despite this caveat though, knowing these attributes can come in handy for those special projects where a bit of movement is needed.

Next time you’re tinkering around with HTML, try incorporating the <marquee> tag and play around with its attributes. You might surprise yourself by how much you can do with such a simple element!

<marquee> Tag Examples and Their Outputs

Dicing into the world of HTML, I’ve found that one tag often misused or misunderstood is the <marquee> tag. It’s a fascinating tool when wielded correctly, so let’s dive in with some illustrative examples.

Here’s a simple example of how to use the <marquee> tag:

<marquee>This text will move</marquee>

The output from this code would be: “This text will move” scrolling horizontally across your screen. A straightforward implementation but it clearly demonstrates the basic functionality.

But don’t stop there! You can customize how your marquee behaves using several attributes. For instance:

<marquee direction="up">This text will move upwards</marquee>

In this case, “This text will move upwards” does exactly what you’d expect – it moves vertically up your screen.

Another attribute you might find useful is scrollamount. This adjusts the speed at which your text scrolls:

<marquee scrollamount="20">This text will quickly move</marquee>

Now, “This text will quickly move” indeed zips across your screen at a much faster pace than before!

It’s important to note that while <marquee> can bring some dynamic movement to static web pages, overuse or misuse can lead to poor user experience and accessibility issues. Here are some common mistakes folks make when utilizing this tag:

So go forth and experiment with the <marquee> tag, but do keep your users’ experience in mind. Happy coding!

Conclusion: Mastering the HTML <marquee> Tag

So, we’ve reached the end of our journey with the HTML <marquee> tag. It’s been quite the ride, hasn’t it? From understanding its basic usage to exploring various attributes and diving into hands-on examples, I trust you’ve gained valuable insight into this unique HTML element.

Now, let me remind you that while <marquee> is a fun feature to use on your web page, it’s important not to overuse it. Why? Well, for starters excessive movement on your site can be distracting or even annoying for users.

<marquee>This is a simple marquee text.</marquee>

That’s an example of how straightforward using this element can be. Yet remember that <marquee> also has some attributes like direction, behavior and scrollamount.

<marquee direction="up" behavior="alternate" scrollamount="2"> This text will bounce up and down at a slow pace </marquee>

In that snippet, we’ve got our text moving up and down in an alternate pattern at a slower pace than default. Neat trick right?

However,in my experience,the most common mistake folks make is neglecting to close their tags properly.

<!-- Incorrect -->
<marquee> This text won't scroll because of missing closing tag

<!-- Correct -->
<marquee> Now it scrolls! </marquee>

Keep an eye out for such mistakes! They’re easy to overlook but can cause big headaches if left uncorrected.

Finally,I’d urge you all not just to stick with what we’ve covered here today but also experiment on your own with different combinations of attributes and values. Practice makes perfect after all!

And there you have it – everything I know about mastering the HTML <markee> tag condensed into one blog post. Here’s hoping you found it helpful and informative. Happy coding!

Cristian G. Guasch

Hey! I'm Cristian Gonzalez, I created HTML Easy to help you learn HTML easily and fast.

Related articles