Scrolling Text
This page contains copy/paste codes for scrolling text.
Scrolling Text using CSS
Here's an example of using a CSS marquee to create scrolling text. This method is standards-compliant as it uses CSS animations to achieve the scrolling effect.
You can also use CSS to create slide-in text, vertical scrolling, bouncing text etc.
HTML <marquee>
Element
The following examples use the HTML <marquee>
tag. As with the CSS method, the HTML method can also be used to give the text a horizontal scroll (from right to left, left to right), a vertical scroll (top to bottom, or bottom to top), as well as a bounce effect.
Non-Standard Tag
The <marquee>
tag isn't an offical HTML tag. See CSS marquees for a standards-compliant marquee.
Right to Left (RTL)
This section contains text that scrolls horizontally (right to left, left to right, or a combination). As you can see, there are a number of options with your horizontal scroll.
Slide-In Text
This text slides in from the right, then stays where it is. You will need to refresh this page to see the effect again.
Example:
Continuous scrolling text (RTL)
Example:
Faster Scrolling
This example uses scrollamount="30"
to increase the scroll speed.
Faster scrolling works better on continuous scrolling as opposed to slide-in text. This is because slide-in text stops after sliding in. If it slides in too fast, many users might miss the slide-in effect altogether.
Example:
Left to Right (LTR)
Slide-In Text
This text slides in from the left, then stays where it is. You will need to refresh this page to see the effect again.
Example:
Continuous scrolling text (LTR)
Example:
Text bouncing back and forth
Normal Speed
This text bounces at the default speed.
Example:
Faster Bounce
This example uses scrollamount="30"
to speed up the scrolling/bouncing text.
Example:
Text Scrolling Up
This text has a vertical scroll - it starts at the bottom and moves up. As with some of the previous examples, you can adjust the scroll speed by using the scrollamount
attribute. You could also create a vertical slide by using behavior="slide"
.
Example:
Text Scrolling Down
This text also has a vertical scroll, but this time it starts at the top and moves down.
Example:
Various Scrolling Speeds
This example demonstrates 3 different scrolling speeds.
Example:
Jumping Text
The following example uses the scrolldelay
attribute to slow the scrolling text down and make it look like it's jumping across the screen. Actually, the example also uses the scrollamount
attribute to increase the size of each jump.
Example:
Browser Compatibility
Some browsers don't render the jumping effect. Instead, the text will scroll smoothly.
Marquee Attributes
The <marquee>
tag accepts a number of attributes (some of which are included in the above examples). Feel free to experiment with these settings to see the effect they have on your scrolling text. The full list of attributes are:
width | Sets the width of the marquee | scrollamount | How far to jump as it moves |
height | Sets the height of the marquee | loop | How many times it should loop |
direction | Sets the direction of the marquee | bgcolor | Sets the background color of the marquee |
behavior | Whether to slide, bounce, or scroll | hspace | Sets the amount of horizontal space around the marquee |
scrolldelay | How long the marquee should wait before each jump | vspace | Sets the amount of vertical space around the marquee |
Falling Text
You can use scrolling text for some great effects:
HTML Reference
-
HTML Tutorial
Free HTML tutorial that explains how to code in HTML.
This tutorial explains what HTML elements and attributes are, and how to use them.
I explain the basics, such as what you need in order to write HTML and how to create your first web page.
I then cover other HTML topics including tables, adding color, images, forms, image maps, iframes, meta tags, and more.
I also explain the difference between HTML and CSS (and when to use each one).
Go to HTML Tutorial -
HTML Tags
Full list of all HTML elements.
This is an alphabetical list of HTML elements, linking to a full page of details for each element.
All elements are based on the official HTML5 specification, and include usage notes, full attribute list, as well as links to the various specifications for each element (i.e. HTML4 spec, HTML5 spec, WHATWG spec).
Go to HTML Tags -
CSS Properties
Full list of CSS properties.
Alphabetical list of CSS properties as per the W3C specifications.
CSS stands for Cascading Style Sheets. CSS is the standard way to style web pages.
You can use CSS to set the style for a whole website in one place. CSS allows you to set colors, fonts, widths, heights, margins, padding, and much more.
Go to CSS Properties