How to Write HTML for a Scrolling Message
A Web programmer has several ways to cause text or images to scroll across the screen when a Web page is read, but only one way to do it in plain HTML, without the use of JavaScript or other enhanced Web programming languages: the MARQUEE tag. Like most HTML tags, the MARQUEE tag supports a set of optional "attributes," which define the behavior of the marquee.
Instructions
-
-
1
Go to the point in your HTML file where you want to insert the scrolling message.
-
2
Between the MARQUEE tags, insert whatever text or images you want to scroll, as follows:
<MARQUEE>
This is a scrolling message! <IMG SRC="image.jpg">
</MARQUEE>
-
-
3
Add various attributes to the opening MARQUEE tag to change the appearance and behavior of the marquee. For example:
<MARQUEE WIDTH="50%" HEIGHT=50 DIRECTION=RIGHT LOOP=3 BEHAVIOR=SLIDE>
This is a scrolling message!
</MARQUEE>
This will scroll a message right-to-left across a space 50 pixels high and 50 percent of the width of the user's browser window. The message will scroll three times and then stop on the right side of the marquee and remain still until the user reloads or revisits the page. The "BEHAVIOR=SLIDE" attribute is what causes the message to stop; without it, it will scroll off the right side and disappear after the third loop. Without a LOOP attribute, the message will loop infinitely. You can use as many, or as few, attributes as you want.
-
1
Tips & Warnings
Learn more about the MARQUEE tag and the attributes available for it by following the link in "References."
The MARQUEE tag is not guaranteed to work uniformly across all browsers and operating systems; furthermore, many Web users find it annoying. Used sparingly and carefully, there's nothing wrong with the tag, but be aware of its limitations. For more complex and reliable scrolling messages, consider using JavaScript rather than HTML.