This HTML term Marquee is used to create a scrolling or sliding text. The text can move across the screen horizontally or vertically at a certain speed determined by you. Note, however, that while it looks nice to have scrolling announcements, advertisements, quotations, or links, having too much animation in your Blog may distract and irritate your readers. We had earlier created a line of scrolling text in the Header of our Quotes Blog to let you have an idea what you can do for your Blog. Also, animated tags like this are not W3C-compliant. Microsoft came up with the marquee tag and while most browsers support it, W3 did not accept it. We shall be discussing this in later articles on CSS3 and JavaScript alternatives.
For this tutorial, we begin with a short explanation of what the attributes do before giving you examples of how these attributes can be applied.
Marquee Attributes
behavior="scroll" behavior="alternate" behavior="slide" |
|---|
This defines how the text will move. The default is Scroll. If the behavior is not specified, the text scrolls by moving from one end to another. Where the behavior is Alternate, the text will move back and forth. The Slide seems to have the same effect as Scroll in Firefox browser. In Internet Explorer, the text under Slide may move to one end and stop.
direction="left" direction="right" direction="up" direction="down" |
|---|
The default is "left", meaning that if no direction is specified, the text will move from right to left.
loop="3" |
|---|
This sets the number of times the marquee will scroll. For example, in Internet Explorer, if the number is 3, the text will scroll 3 times and stop. This command might be ignored by Firefox and the text continues to scroll. For both browsers, if no value is specified or if this attribute is omitted, the marquee will scroll or loop continuously.
scrollamount="1" |
|---|
This is the amount of scrolling (in pixels). If the number is 1, the text moves by 1 pixel each time and therefore scrolls at a slow pace. If this attribute is not stated, the default value is 6. The higher the number, the faster the text scrolls.
scrolldelay="100" |
|---|
This is used to set the interval between each scroll movement in milliseconds. The default value is 85. Here, the higher the value, the slower the text scrolls. A value that is smaller than 60 would be ignored and replaced by the value 60. In Internet Explorer, if you really want the text to zoom at lightning speed, you can set a small delay like 20 and specify the truespeed attribute as true (see below).
truespeed="true" truespeed="false" |
|---|
This tells the browser whether or not to stick to the scrolldelay values lower than 60 that you have set. The default value is false and the browser will ignore values less than 60. Set it as true if you want the browser to adhere to the low scrolldelay value and have the text scroll very fast.
bgcolor: rgb(255,0,0)">#XXXXXX" |
|---|
Should you want a background color for the scrolling text, you can specify the color code into #XXXXXX. You may refer to the HTML Color Code Chart for the color codes.
height="50px" height="80%" |
|---|
You can specify the height of the marquee box in pixels or percentage value. The default value is the height of the contained text.
width="200px" width="80%" |
|---|
Similarly, you can set the width of the marquee box in pixels or percentage value. The default width is the width of the frame that the marquee appears in.
vspace="20px" vspace="80%" |
|---|
In Internet Explorer, you can set the top and bottom margins outside the scrolling text by stating a vspace (vertical space) margin in pixels or percentage value.
hspace="20px" hspace="80%" |
|---|
You can also set the left and right margins outside the scrolling text by stating a hspace (horizontal space) margin either in pixels or percentage value.
Where to place the marquee code
You can place the scrolling text either in your Header, Footer, Sidebar, or blog post.
To have it above or below the Header or Blog Posts, see that you are able to Add Page Element in the Header and Post Body.
Go to Template -> Page Elements -> Add a Page Element, select HTML/JavaScript to add the marquee code.
If you want the text to be in your Posts, just like what you see in this post, see that you are in the “Edit HTML” mode and not “Compose” mode when you add the marquee code.
Marquee HTML Code
The basic code to add is this:-
Example 1
<marquee bgcolor="#ffffcc">Text scrolls from right to left by default.</marquee> |
|---|
Notice that by default, the text scrolls from right to left, and it loops continuously. You can of course change the background color by specifying the Hexadecimal color code under bgcolor.
Further Examples of the Marquee code, applying the attributes discussed above:-
Example 2
<marquee behavior="alternate" width="80%" bgcolor="#ffffcc">Bouncing text using the alternate behavior.</marquee> |
|---|
Here, the text bounces from one side to the other and the width of the text box has been reduced to 80%.
Example 3
<marquee scrolldelay="150" direction="up" width="300px" height="100px" bgcolor="#ffffcc">Text scrolls upwards. For the text to appear in the next line, add this tag <p></p> after the previous line.</marquee> |
|---|
The scrolldelay has been set at 150. Increase this value if you want a slower speed.
Example 4
<marquee hspace="50%" direction="down" scrollamount="2" height="100px" bgcolor="#ffffcc">Text scrolls downwards. For the text to appear in the next line, add this tag <p></p> after the previous line.</marquee> |
|---|
In this example, we use scrollamount to control the speed. The higher the value, the faster the speed. In Internet Explorer, you will see the left and right margins set under hspace.
Change Font style and Color of text
Notice in the above examples that the text is black. If you want a different color or style for your text, you can set the style of the text before the marquee code. Here are some examples:-
Example 5
<span style="color:#F6358A; font-weight:bold;"><marquee direction="right" scrollamount="3" bgcolor="#333333">Text scrolls from left to right.</marquee></span> |
|---|
What we have done here is to specify a color for the text. You can look up the Color Code Chart for more colors.
Example 6
<span style="color:#6AFB92; font-size:xx-large; font-family:fantasy; font-weight:bold;"><marquee direction="right" scrollamount="3" bgcolor="#333333">Text scrolls from left to right.</marquee></span> |
|---|
You can set the font-family for the text. It can be a generic font like cursive, serif, monospace, fantasy and so on. It can also be a specific font family like times, arial, courier, verdana, etc. You can state the font-size as xx-small, x-small, small, smaller, xx-large, x-large, large, larger, or a percentage value.
Update:
Pause/Stop and Start a Scroll
Readers have asked whether the scrolling text can be paused when a visitor moves his mouse cursor over the text. This is useful when he wants to read the text or click a link with the text. To start and start a marquee, the additional arguments used are the "onmouseover" and "onmouseout" events to add a simple JavaScript. It will pause the scrolling text when the mouse is over it and resume the scroll when the mouse leaves the text.
Example 7
<marquee bgcolor="#ffffcc" onmouseover="this.stop()" onmouseout="this.start()">Text scroll pauses when the mouse hovers over it and starts again when the mouse is moved out of the text.</marquee> |
|---|
Scrolling Link List
If you are interested in having a Scrolling Link List, we have explained how you can do it in our article on Numbered List and Bulleted List.
© Tips for New Bloggers




16 comments:
Hello
Very interesting.
How would you insert links to your articles, so people can acces to your older posts within this scroller.
thank you in advance
chris
Hi HSI Pictures
Are you familiar with HTML for links - "a href" tags? You can insert them amid your text or in place of the text.
If you know the HTML for ordered or unorder lists ("ul" and "li") tags, you can also add them into the text. We shall probably come up with an article on the HTML for link lists.
We have now a section in our article Numbered List and Bulleted List explaining how we can include links within the marquee and scrolling tags.
this is very nice. Is there actually the possibility to make the scroller stop for some time? meaning: the text scrolls and appears completely on the screen, then waits a few secs, then starts scrolling again, leading to the following text.
thanks
giulia
Hi Anonymous
It can be done using Scripts. Since we are only talking about using HTML to scroll the text in this article, we have not covered that. Perhaps we'll write about it in future.
How can I start the scrolling immediately after the page loads? It will only start when I mouse over. I have s slow connection and when the download was complete the pare resized and the marquee didn't work again.
Hi Hathor
If you see the scrolling text in the Recent Updates in our left sidebar (inserted using Page Element) or the examples in this article, the scroll starts upon page load and not mouseover. The slight delay caused by the page load time should not change or affect the code. Try with some of the codes given in our examples and see if they work for you.
hi bizwhiz,
I have added the same in my blog in the sidebar. but strangely enough the text is not scrolling. i am using the minima template.
will be grateful if you could check my blogs page source and let me know the problem.
http://thinkersonmove.blogspot.com
Thanks,
Nihar
Hi Nihar
You added a lot of other styles to that widget too. Why don't you try taking out the marquee part and pasting it into a new HTML/JavaScript page element and view it.
Hi,
I think your blog is the best thing ever, I started blogging and I like to try out new ways of doing things. I added extra page elements and now I have added scrolling text. My question is how do I change the color of the text, you talk about it but I could not see any code for it, there is code to change the font to bold/italic and changing the background color am I missing something. Thank for any help proved
Newblog51
Hi L.I.S.T.
Some bits of the code went missing. We have re-inserted that missing code. Thanks for pointing that out.
very nice blog. u are doing not a good job but a very nice job i dont have words to praise you. may the lord grant you all your wishes.
keep up the good work man.
I have a small problem on my blog
http://belgaumblog.blogspot.com/
there is a marquee but its color is not matching with the background color how do i know my background color, i tried in edit html seeign the source but i wasnt able to match the color.
Hi ukmad
Try leaving out the bgcolor. Just use the code and enter the scrolling text.
yes thanks it worked correctly as i wanted it. background color went off. thnx again man
may god bless you a lot
Your blog makes life sooooooooo much easier!! :)
Thanks a million
-Seasons
Ok, I am really brand new at this where do I actually put the code for this. What spot exactly in my template? I would like to put it to the right of my jpg in my header
I have something to say ...